安装 XML::Parser,但由于依赖 Expat,它无法运行

安装 XML::Parser,但由于依赖 Expat,它无法运行

我正在尝试安装XML::解析器,但由于某种原因它失败了:

cpanm (App::cpanminus) 1.7040 on perl 5.022001 built for x86_64-linux-gnu-thread-multi
Work directory is /root/.cpanm/work/1500726452.8458
You have make /usr/bin/make
You have LWP 6.15
You have /bin/tar: tar (GNU tar) 1.28
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching XML::Parser () on cpanmetadb ...
--> Working on XML::Parser
Fetching http://www.cpan.org/authors/id/T/TO/TODDR/XML-Parser-2.44.tar.gz
-> OK
Unpacking XML-Parser-2.44.tar.gz
Entering XML-Parser-2.44
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.04_01)
Configuring XML-Parser-2.44
Running Makefile.PL

Expat must be installed prior to building XML::Parser and I can't find
it in the standard library directories. Install 'expat-devel' (or
'libexpat1-dev') package with your OS package manager. See 'README'.

Or you can download expat from:

http://sourceforge.net/projects/expat/

If expat is installed, but in a non-standard directory, then use the
following options to Makefile.PL:

    EXPATLIBPATH=...  To set the directory in which to find libexpat

    EXPATINCPATH=...  To set the directory in which to find expat.h

For example:

    perl Makefile.PL EXPATLIBPATH=/home/me/lib EXPATINCPATH=/home/me/include

Note that if you build against a shareable library in a non-standard location
you may (on some platforms) also have to set your LD_LIBRARY_PATH environment
variable at run time for perl to find the library.

Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for XML::Parser::Expat
Writing MYMETA.yml and MYMETA.json
Generating a Unix-style Makefile
Writing Makefile for XML::Parser
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have Test::More 0 ... Yes (1.302086)
Checking if you have LWP::UserAgent 0 ... Yes (6.15)
Building and testing XML-Parser-2.44
cp Parser/Encodings/big5.enc blib/lib/XML/Parser/Encodings/big5.enc
cp Parser/Encodings/iso-8859-3.enc blib/lib/XML/Parser/Encodings/iso-8859-3.enc
cp Parser/Encodings/windows-1255.enc blib/lib/XML/Parser/Encodings/windows-1255.enc
cp Parser/Encodings/ibm866.enc blib/lib/XML/Parser/Encodings/ibm866.enc
cp Parser/Encodings/iso-8859-8.enc blib/lib/XML/Parser/Encodings/iso-8859-8.enc
cp Parser/Encodings/iso-8859-7.enc blib/lib/XML/Parser/Encodings/iso-8859-7.enc
cp Parser/Encodings/README blib/lib/XML/Parser/Encodings/README
cp Parser/Encodings/iso-8859-2.enc blib/lib/XML/Parser/Encodings/iso-8859-2.enc
cp Parser/Encodings/x-euc-jp-unicode.enc blib/lib/XML/Parser/Encodings/x-euc-jp-unicode.enc
cp Parser/LWPExternEnt.pl blib/lib/XML/Parser/LWPExternEnt.pl
cp Parser/Style/Debug.pm blib/lib/XML/Parser/Style/Debug.pm
cp Parser/Encodings/windows-1252.enc blib/lib/XML/Parser/Encodings/windows-1252.enc
cp Parser/Style/Tree.pm blib/lib/XML/Parser/Style/Tree.pm
cp Parser/Encodings/x-sjis-jisx0221.enc blib/lib/XML/Parser/Encodings/x-sjis-jisx0221.enc
cp Parser/Encodings/x-euc-jp-jisx0221.enc blib/lib/XML/Parser/Encodings/x-euc-jp-jisx0221.enc
cp Parser/Style/Objects.pm blib/lib/XML/Parser/Style/Objects.pm
cp Parser/Encodings/x-sjis-unicode.enc blib/lib/XML/Parser/Encodings/x-sjis-unicode.enc
cp Parser/Encodings/windows-1250.enc blib/lib/XML/Parser/Encodings/windows-1250.enc
cp Parser/Encodings/Japanese_Encodings.msg blib/lib/XML/Parser/Encodings/Japanese_Encodings.msg
cp Parser/Encodings/x-sjis-jdk117.enc blib/lib/XML/Parser/Encodings/x-sjis-jdk117.enc
cp Parser/Encodings/iso-8859-4.enc blib/lib/XML/Parser/Encodings/iso-8859-4.enc
cp Parser/Encodings/x-sjis-cp932.enc blib/lib/XML/Parser/Encodings/x-sjis-cp932.enc
cp Parser/Encodings/koi8-r.enc blib/lib/XML/Parser/Encodings/koi8-r.enc
cp Parser/Style/Stream.pm blib/lib/XML/Parser/Style/Stream.pm
cp Parser/Encodings/iso-8859-5.enc blib/lib/XML/Parser/Encodings/iso-8859-5.enc
cp Parser/Encodings/windows-1251.enc blib/lib/XML/Parser/Encodings/windows-1251.enc
cp Parser/Style/Subs.pm blib/lib/XML/Parser/Style/Subs.pm
cp Parser/Encodings/iso-8859-9.enc blib/lib/XML/Parser/Encodings/iso-8859-9.enc
cp Parser.pm blib/lib/XML/Parser.pm
cp Parser/Encodings/euc-kr.enc blib/lib/XML/Parser/Encodings/euc-kr.enc
make[1]: Entering directory '/root/.cpanm/work/1500726452.8458/XML-Parser-2.44/Expat'
cp Expat.pm ../blib/lib/XML/Parser/Expat.pm
Running Mkbootstrap for XML::Parser::Expat ()
chmod 644 "Expat.bs"
"/usr/bin/perl" "/usr/share/perl/5.22.1/ExtUtils/xsubpp" -noprototypes -typemap "/usr/share/perl/5.22/ExtUtils/typemap" -typemap "typemap"  Expat.xs > Expat.xsc && mv Expat.xsc Expat.c
x86_64-linux-gnu-gcc -c   -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"2.44\" -DXS_VERSION=\"2.44\" -fPIC "-I/usr/lib/x86_64-$
Expat.xs:12:19: fatal error: expat.h: No such file or directory
compilation terminated.
Makefile:320: recipe for target 'Expat.o' failed
make[1]: *** [Expat.o] Error 1
make[1]: Leaving directory '/root/.cpanm/work/1500726452.8458/XML-Parser-2.44/Expat'
Makefile:595: recipe for target 'subdirs' failed
make: *** [subdirs] Error 2
-> FAIL Installing XML::Parser failed. See /root/.cpanm/work/1500726452.8458/build.log for details. Retry with --force to force install it.

经过一番研究,我发现它需要“expat”,所以我已经使用 apt-get 安装了它:

apt-get install expat
Reading package lists... Done
Building dependency tree
Reading state information... Done
expat is already the newest version (2.1.0-7ubuntu0.16.04.3).
0 upgraded, 0 newly installed, 0 to remove and 150 not upgraded.

但是,即使重新运行它之后我仍然收到此错误(locate Expat.o没有结果,即使在之后updatedb

我错过了什么?

答案1

为了获取所需的库和头文件,您应该按照输出中的这一行:

使用您的操作系统包管理器安装“expat-devel”(或“libexpat1-dev”)包。

只是expat不会为您提供您需要链接的库和头文件。

相关内容