在x64位机器上使用libxml动态库时,发现从源码安装php时候老是make不上,即时指定libxml的安装路径也是无效果,make错误如下
ext/libxml/.libs/libxml.o(.text+0x555): In function `_php_libxml_free_error':进入libxml安装目录,直接查看lib库中是否有xmlTextWriterFlush这个引用:
/home/lijunlia/opt/src/php-5.2.5/ext/libxml/libxml.c:441: undefined reference to `xmlResetError'
ext/libxml/.libs/libxml.o(.text+0x5a9): In function `_php_list_set_error_structure':
/home/lijunlia/opt/src/php-5.2.5/ext/libxml/libxml.c:455: undefined reference to `xmlCopyError'
ext/libxml/.libs/libxml.o(.text+0xf6a): In function `zm_activate_libxml':
/home/lijunlia/opt/src/php-5.2.5/ext/libxml/libxml.c:651: undefined reference to `xmlParserInputBufferCreateFilenameDefault'
ext/libxml/.libs/libxml.o(.text+0xf76):/home/lijunlia/opt/src/php-5.2.5/ext/libxml/libxml.c:652: undefined reference to `xmlOutputBufferCreateFilenameDefault'
...
/home/lijunlia/opt/src/php-5.2.5/ext/xmlwriter/php_xmlwriter.c:1523: undefined reference to `xmlNewTextWriterMemory'
ext/xmlwriter/.libs/php_xmlwriter.o(.text+0x1e7d): In function `php_xmlwriter_flush':
/home/lijunlia/opt/src/php-5.2.5/ext/xmlwriter/php_xmlwriter.c:1581: undefined reference to `xmlTextWriterFlush'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
$nm libxml2.so |grep xmlTextWriterFlush为什么有上面这个错误呢?查了好久,发现x64的平台寻找lib时,首先会寻找/usr/lib64这个目录,我发现这个目录里面有一个libxml2.so,是一个老版本,导致一些东西没有定义:
00000000000f3060 T xmlTextWriterFlush
$nm libxml2.so.2.5.10 |grep xmlTextWriterFlush郁闷了老半天,知道错误后,然后删除lib64目录下的一些老版本的libxml2.so,然后重新configure:
nm: libxml2.so.2.5.10: no symbols
$nm libxml2.so.2.6.30 |grep xmlTextWriterFlush
00000000000f3060 T xmlTextWriterFlush
./configure --prefix=/home/lijunlia/opt/usr/local/php --with-apxs2=/home/lijunlia/opt/usr/local/apache2/bin/apxs --with-mysql=/home/lijunlia/opt/usr/local/mysql --with-config-file-path=/home/lijunlia/opt/etc --with-gd --with-zlib --with-jpeg-dir=/usr/local/jpeg --with-libxml-dir=/usr --enable-sockets --with-iconv --enable-mbstring --enable-soap --with-curl --with-freetype-dir=/usr/local --with-pgsql=/home/lijunlia/opt/usr --enable-zend-multibyte终于出现了:
Build complete.作此笔记,以儆效尤。
Don't forget to run 'make test'.