2013-07-10 97 views
1

我需要安裝perl模塊XML-LibXML。我已經下載並嘗試安裝。它說不能鏈接libxml2。然後我已經下載libxml2並安裝,然後再次嘗試,但也沒有成功。
所以我應該知道如何鏈接這個已安裝的libxml2。
我是否需要添加的libxml2安裝目錄(/安裝/其它/ lib中)到文件「/etc/ld.so.conf中」和更新通過運行動態加載緩存:LDCONFIG無法鏈接libxml2

bash-3.2$ wget http://search.cpan.org/CPAN/authors/id/S/SH/SHLOMIF/XML-LibXML-2.0019.tar.gz 
bash-3.2$ tar zxvf XML-LibXML-2.0019.tar.gz 
bash-3.2$ pwd 
/install/others/XML-LibXML-2.0019 

bash-3.2$ perl Makefile.PL LIBS='-L/install/others/lib' INC='-I/install/others/include' 
enable native perl UTF8 
Checking for ability to link against xml2...no 
Checking for ability to link against libxml2...libxml2, zlib, and/or the Math library (-lm) have not been found. 
Try setting LIBS and INC values on the command line 
Or get libxml2 from 
http://xmlsoft.org/ 
If you install via RPMs, make sure you also install the -devel 
RPMs, as this is where the headers (.h files) are. 

Also, you may try to run perl Makefile.PL with the DEBUG=1 parameter 
to see the exact reason why the detection of libxml2 installation 
failed or why Makefile.PL was not able to compile a test program. 
bash-3.2$ 
bash-3.2$ 
bash-3.2$ 
bash-3.2$ 
bash-3.2$ perl Makefile.PL PREFIX=/install/others LIBS='-L/install/others/lib' INC='-I/install/others/include' 
enable native perl UTF8 
Checking for ability to link against xml2...no 
Checking for ability to link against libxml2...libxml2, zlib, and/or the Math library (-lm) have not been found. 
Try setting LIBS and INC values on the command line 
Or get libxml2 from 
http://xmlsoft.org/ 
If you install via RPMs, make sure you also install the -devel 
RPMs, as this is where the headers (.h files) are. 

Also, you may try to run perl Makefile.PL with the DEBUG=1 parameter 
to see the exact reason why the detection of libxml2 installation 
failed or why Makefile.PL was not able to compile a test program. 
bash-3.2$ 

以下是DEBUG = 1添加輸出

bash-3.2$ pwd 
/install/others/XML-LibXML-1.31 
bash-3.2$ perl Makefile.PL LIBS='-L/install/others/lib -lxml2 -lz -lm' INC='-I/install/others/include/libxml2' DEBUG=1 
running xml2-config... xml2-config --version 
failed 
*** backticks call to 'xml2-config --version' failed at Makefile.PL line 212. 
using fallback values for LIBS and INC 
options: 
    LIBS='-L/usr/local/lib -L/usr/lib -lxml2 -lz -lm' 
    INC='-I/usr/local/include -I/usr/include' 
If this is wrong, Re-run as: 
    $ /usr/bin/perl Makefile.PL LIBS='-L/path/to/lib' INC='-I/path/to/include' 

looking for -lxml2... /usr/bin/perl Makefile.PL 'INC=-I/usr/local/include -I/usr/include' 'LIBS=-L/usr/local/lib -L/usr/lib -lxml2 -lz -lm' 
INC = -I/usr/local/include -I/usr/include 
LIBS = -L/usr/local/lib -L/usr/lib -lxml2 -lz -lm 
Writing Makefile for Conftest 
make test 'OTHERLDFLAGS=-lxml2' 
cp Conftest.pm blib/lib/Conftest.pm 
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap Conftest.xs > Conftest.xsc && mv Conftest.xsc Conftest.c 
gcc -c -I/usr/local/include -I/usr/include -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION=\"1\" -DXS_VERSION=\"1\" -fPIC "-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE" Conftest.c 
Conftest.xs:11: warning: return type defaults to âintâ 
Running Mkbootstrap for Conftest() 
chmod 644 Conftest.bs 
rm -f blib/arch/auto/Conftest/Conftest.so 
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic Conftest.o -lxml2 -o blib/arch/auto/Conftest/Conftest.so  \ 
      -L/usr/local/lib -L/usr/lib -lxml2 -lz -lm \ 

/usr/bin/ld: cannot find -lxml2 
collect2: ld returned 1 exit status 
make: *** [blib/arch/auto/Conftest/Conftest.so] Error 1 
system call to 'make test 'OTHERLDFLAGS=-lxml2'' failed at Makefile.PL line 188. 
no 
libxml2 not found 
Try setting LIBS and INC values on the command line 
Or get libxml2 from 
    http://www.libxml.org/ 
If you install via RPMs, make sure you also install the -devel 
RPMs, as this is where the headers (.h files) are. 
bash-3.2$ 

它是不是找我的本地目錄中,它正在尋找

INC = -I/usr/local/include -I/usr/include 
LIBS = -L/usr/local/lib -L/usr/lib -lxml2 -lz -lm 

注:我沒有root訪問權限和我的歌劇系統是Linux RedHat。

在此先感謝

+2

*如果你通過RPM包安裝,請確保您還安裝-devel RPM包,因爲這是頭(.h文件)是*。所以,有你安裝了頭文件?如果不是,請安裝它們並重試Perl模塊安裝。如果是的話,他們在哪裏? (另外,爲什麼你要手動安裝模塊,而不是像cpanm一樣使用local :: lib工具?) – amon

+0

您是否按照錯誤消息中的建議嘗試了DEBUG = 1參數? –

+0

@amon:他沒有root權限,所以股票rpm安裝不起作用。 –

回答

0

如果你沒有root訪問權限您嘗試使用perlbrew:http://perlbrew.pl/

然後,你可以很容易地安裝外國人:: XML ::的libxml(http://corion.net/perl-dev/Alien-XML-LibXML.html

它安裝libxml僅適用於本地Perl。

之後,應該成功安裝XML-LibXML。

步驟:

1)安裝與perlbrew本地Perl,以保持系統的perl乾淨

2)cpanm從安裝外國人:: XML ::的libxml perlbrew

3)安裝XML-的libxml

+0

[Alien :: LibXML](http://p3rl.org/Alien::LXXML)存在於CPAN上。 – daxim

+0

不,請安裝Alien:libxml不要讓xml :: libxml安裝,因爲它還會在默認庫路徑中查找libxml。 – netawater

1

你需要頭文件。

它們可作爲libxml源分佈的一部分,例如, here。將文件系統中的libxml.../include目錄解壓縮到某個位置,並將該目錄包含在撥打電話的-I標誌中。錯誤信息還表明zlib和libm無法在您的系統上找到。他們可能位於非標準/usr/lib...目錄中,但會出現。請在撥打電話的-L選項中包含找到的庫。

+0

-1沒有提到編譯未安裝的頭文件的缺點。 – daxim

0

安裝外國人::的libxml或下載二進制的libxml爲您的Linux發行版,

"export XMLPREFIX=$YOURLIBXMLPREFIX" $$ YOURLIBXMLPREFIX /斌/ XML2-配置是OK。

然後通過CPAN安裝XML ::的libxml