V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
lzwt806
V2EX  ›  Linux

perl 的 XML::Parser 模块求助

  •  
  •   lzwt806 · 2020-02-07 14:40:49 +08:00 · 3932 次点击
    这是一个创建于 1531 天前的主题,其中的信息可能已经有所发展或是发生改变。
    各位前辈们好!

    最近更新 CDLinux (我是 CDLinux 的后期版本维护者)遇到点问题,一直困扰着我,很多工作因为它无法续继进行,所以请知道的前辈们相助,感谢!

    编译 Mesa,glibc,llvm,pcb-gtk 等很多软件都要用到 perl 的模块[XML::Parser],如果没有就就会有以下提示:

    checking for perl... /usr/bin/perl
    checking for perl >= 5.8.1... 5.24.0
    checking for XML::Parser... configure: error: XML::Parser perl module is required for intltool

    但我试了很多方法都安装不上,比如以下的方法:

    # perl -MCPAN -e shell
    # install XML::Parser::Expat //某些时侯提示缺少 expat.xx ,顺便一起安装

    结果不行提示:

    Would you like me to append that to /root/.bashrc now? [yes] no
    commit: wrote '/root/.cpan/CPAN/MyConfig.pm'

    You can re-run configuration any time with 'o conf init' in the CPAN shell
    Terminal does not support AddHistory.

    cpan shell -- CPAN exploration and modules installation (v2.11)
    Enter 'h' for help.

    继续重复上面的 cpan[1]> install XML::Parser
    等了很久,操行了无数操作后得到如下结果:

    All tests successful.
    Files=15, Tests=140, 0 wallclock secs ( 0.05 usr 0.02 sys + 0.41 cusr 0.07 csys = 0.55 CPU)
    Result: PASS
    TODDR/XML-Parser-2.46.tar.gz
    Tests succeeded but one dependency not OK (LWP::UserAgent)
    TODDR/XML-Parser-2.46.tar.gz
    [dependencies] -- NA
    Failed during this command:
    OALDERS/libwww-perl-6.43.tar.gz : make_test NO 2 dependencies missing (HTML::Entities,HTML::HeadParser)
    TODDR/XML-Parser-2.46.tar.gz : make_test NO one dependency not OK (LWP::UserAgent)

    cpan[2]>

    ===================================
    那么我下载 XML-Parser-2.46.tar.gz 手动编译安装:

    # perl Makefile.PL
    # perl Makefile.PL PREFIX=/opt/perl INSTALLDIRS=perl
    # make
    # perl -I../blib/lib -I../blib/arch xmlcomments REC-xml-19980210.xml //没做这一步
    # make install

    提示成功,在 /opt/下有 perl 目录,但再次 cd pcb-gtk:
    ./configure --prefix=/usr
    又提示:

    checking for perl... /usr/bin/perl
    checking for perl >= 5.8.1... 5.24.0
    checking for XML::Parser... configure: error: XML::Parser perl module is required for intltool

    我就奇怪了,在这里绕来绕去,花了很多时间也没搞定,望知道的前辈,朋友给点指导,让我顺利完成这次 CDLinux 的更新。
    19 条回复    2020-02-08 17:51:31 +08:00
    churchmice
        1
    churchmice  
       2020-02-07 14:50:20 +08:00
    首先你需要 perldoc XML::Parser 确定你的 perl 能够找到对应的版本
    你装在 /opt 这种目录下一般是要设置 PERL5LIB 变量的,否则 perl 咋知道要去这个目录下找呢?
    churchmice
        2
    churchmice  
       2020-02-07 14:51:29 +08:00
    或者你简单点就把 XML::Parser 装在 /usr/share 下面
    lzwt806
        3
    lzwt806  
    OP
       2020-02-07 14:57:25 +08:00
    @churchmice 前辈你好,按你说的得到如下结果:

    cpan[5]> install lync
    Warning: Cannot install lync, don't know what it is.
    Try the command

    i /lync/

    to find objects with matching identifiers.

    cpan[6]> install html2text.pl
    Warning: Cannot install html2text.pl, don't know what it is.
    Try the command

    i /html2text.pl/

    to find objects with matching identifiers.

    cpan[7]> perldoc XML::Parser
    Running perldoc for module 'XML::Parser'
    Could not run 'which html2text.pl':

    You need to install lynx or html2text.pl to use this feature.
    cpan[8]>

    要不你还是直接告诉我,perllib 的变量在哪里设置?
    是在 /etc/ld.so.conf 里添加一行吗?比如:
    /opt/perl/lib/
    lzwt806
        4
    lzwt806  
    OP
       2020-02-07 15:17:12 +08:00
    @churchmice 前辈
    是在 /etc/ld.so.conf 里添加一行吗?比如:/opt/perl/lib/ ,此方法不行,通不过
    再次按你说的直接安装到 /usr/share 下面,我原来的 perl-5.24 路径:/usr/lib/per5
    那么:

    # perl Makefile.PL
    # perl Makefile.PL PREFIX=/opt/perl INSTALLDIRS=perl5
    # make
    # make install

    得到以下结果:

    chmod 755 ../blib/arch/auto/XML/Parser/Expat/Expat.so
    "/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Expat.bs ../blib/arch/auto/XML/Parser/Expat/Expat.bs 644
    Manifying 1 pod document
    make[1]: Leaving directory '/home/cdl/Desktop/XML-Parser-2.36/Expat'
    Manifying 6 pod documents
    0 15:02# make install
    make: *** No rule to make target 'pure_perl5_install', needed by 'pure_install'. Stop.
    churchmice
        5
    churchmice  
       2020-02-07 15:33:02 +08:00
    @lzwt806 /etc/ld.so.conf 是控制动态链接库,.so 用的
    perl 用 PERL5LIB 这个变量
    lzwt806
        6
    lzwt806  
    OP
       2020-02-07 15:57:47 +08:00
    @churchmice 前辈
    我更正上一条回的笔误:
    # perl Makefile_PL PREFIX=/opt/perl INSTALLDIRS=perl5 写错,正确的是
    # perl Makefile_PL PREFIX=/usr/lib INSTALLDIRS=perl5
    但这样在执行# make install 时通不过,改为:
    # perl Makefile_PL PREFIX=/opt/perl INSTALLDIRS=perl
    可以正常# make install,但再./configure 也是提示找不到 XML::Parser

    "perl 用 PERL5LIB 这个变量",能否给个例子,就以我把 XML::Parser 安装到了 /usr/lib/perl5,完整路径:/usr/lib/perl5/5.24.0/ 这个目录为例,因为我# perl5lib 或# per perl5lib 提示出错。

    另外在 redme 文件里,官方给的这句,我始终没有看明白:
    perl -I../blib/lib -I../blib/arch xmlcomments REC-xml-19980210.xml
    crisewng
        7
    crisewng  
       2020-02-07 18:09:12 +08:00
    用 cpanm 装
    curl -L https://cpanmin.us | perl - --sudo App::cpanminus
    cpanm install XML::Parser
    @lzwt806
    crisewng
        8
    crisewng  
       2020-02-07 18:11:59 +08:00
    Failed during this command:
    OALDERS/libwww-perl-6.43.tar.gz : make_test NO 2 dependencies missing (HTML::Entities,HTML::HeadParser)
    TODDR/XML-Parser-2.46.tar.gz : make_test NO one dependency not OK (LWP::UserAgent)

    这些是有一些依赖没有装全导致的,cpanm 会把依赖给你全都自动装上。
    lzwt806
        9
    lzwt806  
    OP
       2020-02-07 22:38:19 +08:00
    问题已经解决,百度找到的答案:
    1,先安装 libxml-simple-perl //CDLinux 使用的 deb 包,直接解压复制文件到对应的目录即可
    2,# perl -e shell -MCPAN
    3,# install XML::Parser //过程中会补齐一些其它依赖包
    4,设置变量路径,在 /etc/profile 下面添加一行:export PERL5LIB=$PERL5LIB:/usr/lib/perl5/5.24.0/TAP/;
    5,更新变量:# source /etc/profile
    测试可行

    @churchmice 感谢前辈的好心参与
    @crisewng 感谢前辈的回复,我按上面的方法搞定后才看到你的信息,多用了 4 个小时才解决问题。但我后来测试了你说的方法,确实可行,而且完美简单,万分感谢!!!

    希望有遇到同样问题的朋友可以参考以上两个方案。
    我自己之前没碰过 perl,不懂源于我的浅学与无知,操作系统真的是个庞大复杂的工程,涉及方方面面的知识,没有长时间的学习实践和经验积累确实难以精通,我会继续努力,把 CDLinux 维护到我认为理想的状态。

    @crisewng 另外前辈对 Mesa 和 llvm 的编译是否熟悉?这两个也费了我好多时间,特别是 llvm-config 的缺失,让我一直卡在 Mesa 这一步无法继续更新图形界面和一些驱动。如果你能帮助我就最好了,期朌。
    secondwtq
        10
    secondwtq  
       2020-02-08 00:01:24 +08:00
    我不记得 LLVM 有用到 Perl ...
    另外 llvm-config 是要你自己编译的
    lzwt806
        11
    lzwt806  
    OP
       2020-02-08 00:32:39 +08:00
    @secondwtq 编译 llvm 可以使用./autogen.sh 或./config 来完成,但两个都卡住我了,前者提示我安装 Autom4te,我已经装了 automake-1.14.6,后者提示我 --enable-llvm r300 什么的,都是通不过编译。另外 /usr/lib/dri/下有 r600_dri.so 文件,两者有什么区别?为什么不用 r600 而用 r300 ?

    关于 llvm-config 能否给我连接,我看过 llvm 的官网,包括 llvm-dev,都没有提到过 llvm-config,下载页面看到的是如下信息:

    Download LLVM 4.0.0
    Sources:

    LLVM source code (.sig)
    Clang source code (.sig)
    compiler-rt source code (.sig)
    libc++ source code (.sig)
    libc++abi source code (.sig)
    libunwind source code (.sig)
    LLD Source code (.sig)
    LLDB Source code (.sig)
    OpenMP Source code (.sig)
    Polly Source code (.sig)
    clang-tools-extra (.sig)
    LLVM Test Suite (.sig)
    Documentation:

    LLVM (release notes)
    Clang (release notes)
    clang-tools-extra (release notes)
    LLD (release notes)
    libc++
    LLVM Doxygen (.tar.xz)
    Clang Doxygen (.tar.xz)
    clang-tools-extra Doxygen (.tar.xz)
    Pre-Built Binaries:

    Clang for Mac OS X (.sig)
    Clang for FreeBSD10 AMD64 (.sig)
    Clang for FreeBSD10 i386 (.sig)
    Clang for AArch64 Linux (.sig)
    Clang for armv7a Linux (.sig)
    Clang for x86_64 Ubuntu 14.04 (.sig)
    Clang for x86_64 Ubuntu 16.04 (.sig)
    Clang for x86_64 Ubuntu 16.10 (.sig)
    Clang for x86_64 Debian 8 (.sig)
    Clang for MIPS (.sig)
    Clang for MIPSel (.sig)
    Clang for Windows (32-bit) (.sig)
    Clang for Windows (64-bit) (.sig)
    Signed with PGP key 345AD05D.

    望前辈给予帮助。
    secondwtq
        12
    secondwtq  
       2020-02-08 00:47:05 +08:00
    @lzwt806 你是 4.0.0 啊 … 那就不知道了,现在早就 CMake 一把梭了,除了 CMake 没别的依赖。
    另外 LLVM 本身不直接依赖任何驱动。
    “—enable-llvm is required when building r300”是说你编译 mesa 的时候要把 —enable-llvm 这个 flag 加进去。r300 和 r600 应该是不同的驱动

    llvm-config 是 LLVM 的编译产物之一,属于 LLVM 库,不是单独下载的。单独的 llvm-config 没有意义
    lzwt806
        13
    lzwt806  
    OP
       2020-02-08 01:42:58 +08:00
    @secondwtq 刚才下载了 slackware 14.2 的 llvm-3.8,有了 llvm-config,于是./configure 编译 Mesa-17.1.6 (这个版本与一在的系统依赖刚好相符),出现以下错误:

    make[3]: Entering directory '/home/cdl/Desktop/mesa-17.1.6/src/amd'
    make all-am
    make[4]: Entering directory '/home/cdl/Desktop/mesa-17.1.6/src/amd'
    CC common/common_libamd_common_la-ac_binary.lo
    common/ac_binary.c:33:18: fatal error: gelf.h: No such file or directory
    #include <gelf.h>
    ^
    compilation terminated.
    Makefile:910: recipe for target 'common/common_libamd_common_la-ac_binary.lo' failed
    make[4]: *** [common/common_libamd_common_la-ac_binary.lo] Error 1
    make[4]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src/amd'
    Makefile:721: recipe for target 'all' failed
    make[3]: *** [all] Error 2
    make[3]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src/amd'
    Makefile:851: recipe for target 'all-recursive' failed
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src'
    Makefile:642: recipe for target 'all' failed
    make[1]: *** [all] Error 2
    make[1]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src'
    Makefile:642: recipe for target 'all-recursive' failed
    make: *** [all-recursive] Error 1

    在 error: gelf.h: No such file or directory 这里缺文件
    如果不管这些错误直接 make,会有如下警告:

    libtool: warning: relinking 'es1api/libGLESv1_CM.la' 和
    libtool: error: error: relink 'es1api/libGLESv1_CM.la' with the above command before installing it

    重新安装 libtool,并使用 autoreconf -i -f 做兼容处理后,又得到上面的出错信息,试了安装 ppl,也得不到 gelf.h 这个文件,不知何故,看看前辈能不能帮我看看?
    secondwtq
        14
    secondwtq  
       2020-02-08 01:51:21 +08:00
    @lzwt806 你直接搜 gelf.h 呗,应该是 libelf 的
    woodelf
        15
    woodelf  
       2020-02-08 02:18:04 +08:00 via iPhone
    遇到这种各类编译 /依赖问题就不能查查 BLFS 手册么……里面会告诉你为什么有些选项需要开,一个包要怎么编译等等。我做完一遍 BLFS,手工编译了 400+个包,确实感觉到对我帮助很大。现在遇到要手工编译包,首选就是查 LFS/BLFS 手册。
    lzwt806
        16
    lzwt806  
    OP
       2020-02-08 02:36:06 +08:00
    @secondwtq 回前辈,是的,安装了 libelf-0.8.13 ,config 和 mke 不再提示提示任何缺少文件,但在 make install 时还是会提示:

    libtool: warning: relinking 'es1api/libGLESv1_CM*la'
    libtool: error: error: relink 'es1api/libGLESv1_CM*la' with the above command before installing it

    Makefile:1156: recipe for target 'install-libLTLIBRARIES' failed
    make[6]: *** [install-libLTLIBRARIES] Error 1
    make[6]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src/mapi'
    Makefile:2027: recipe for target 'install-am' failed
    make[5]: *** [install-am] Error 2
    make[5]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src/mapi'
    Makefile:1676: recipe for target 'install-recursive' failed
    make[4]: *** [install-recursive] Error 1
    make[4]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src/mapi'
    Makefile:2021: recipe for target 'install' failed
    make[3]: *** [install] Error 2
    make[3]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src/mapi'
    Makefile:851: recipe for target 'install-recursive' failed
    make[2]: *** [install-recursive] Error 1
    make[2]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src'
    Makefile:1008: recipe for target 'install' failed
    make[1]: *** [install] Error 2
    make[1]: Leaving directory '/home/cdl/Desktop/mesa-17.1.6/src'
    Makefile:642: recipe for target 'install-recursive' failed
    make: *** [install-recursive] Error 1

    @woodelf 回前辈,前两天就看了 LFS ( BLFS 和 CLFS ),如果从头构建,按上面的版本一个个安装,都会成功,但现在是要用别人的现成的维护,难度大不少。CDLinux 的原作者老赵曾对我说过:如果 2 年不更新,一但更新就是牵一发动全身。这方面就连 debian,ubuntu 这样的大团队都做不到 10 全 10 美,何况我一个人。
    qakito
        17
    qakito  
       2020-02-08 14:34:41 +08:00
    该发行版没有包管理吗?哼哧哼哧源码编译挺吃力的,尤其是被依赖库的 configure 参数
    z5864703
        18
    z5864703  
       2020-02-08 17:23:24 +08:00
    报错不是说的很明白,缺少依赖 intltool ?
    lzwt806
        19
    lzwt806  
    OP
       2020-02-08 17:51:31 +08:00
    @qakito 没有包管理,主要对 liveCD 做了稳定性可靠性加强,定位移动操作系统,就想着把常用实用的软件一次搞定,一劳永逸。

    @z5864703 确认是重新编译安装的 libtool 最新版本,有空了再深究,10 号要开工了,就想着在开工前利用这 10 几天时间更新一波,这次更新不完就等明年春节再搞。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3934 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 04:17 · PVG 12:17 · LAX 21:17 · JFK 00:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.