使用交叉编译过的xml静态库的问题??
我从网上下载的libxml2-2.6.30,解压后用
./configure --host=arm-linux-gnu --target=arm-linux CC=arm-linux-gcc AR=arm-linux-ar LD=arm-linux-ld RANLIB=arm-linux-ranlib --prefix=/usr/local/arm/3.4.1/arm-linux/
进行配置,然后
make
make install
将/usr/local/arm/3.4.1/arm-linux/lib/libxml2.a和/usr/local/arm/3.4.1/arm-linux/include/libxml2下的包含头文件的文件夹libxml一起拷贝到我的程序文件夹下,用
arm-linux-gcc -Wall -lm -L ./ -I ./ xmlfile.c -o testxml -lxml2
交叉编译,结果出现错误如下:
.//libxml2.a(xmlIO.o)(.text+0xa68): In function `xmlGzfileOpen_real':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1108: undefined reference to `gzdopen'
.//libxml2.a(xmlIO.o)(.text+0xaa8):/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1132: undefined reference to `gzopen'
.//libxml2.a(xmlIO.o)(.text+0xb7c): In function `xmlGzfileOpenW':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1178: undefined reference to `gzdopen'
.//libxml2.a(xmlIO.o)(.text+0xbb0):/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1200: undefined reference to `gzopen'
.//libxml2.a(xmlIO.o)(.text+0xbe8): In function `xmlGzfileRead':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1219: undefined reference to `gzread'
.//libxml2.a(xmlIO.o)(.text+0xc18): In function `xmlGzfileWrite':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1239: undefined reference to `gzwrite'
.//libxml2.a(xmlIO.o)(.text+0xc48): In function `xmlGzfileClose':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1255: undefined reference to `gzclose'
.//libxml2.a(xmlIO.o)(.text+0xccc): In function `xmlFreeZMemBuff':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1361: undefined reference to `deflateEnd'
.//libxml2.a(xmlIO.o)(.text+0x141c): In function `__xmlParserInputBufferCreateFilename':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:2411: undefined reference to `gzread'
.//libxml2.a(xmlIO.o)(.text+0x144c):/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:2416: undefined reference to `gzrewind'
.//libxml2.a(xmlIO.o)(.text+0x1ea0): In function `xmlIOHTTPCloseWrite':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1563: undefined reference to `deflate'
.//libxml2.a(xmlIO.o)(.text+0x2184): In function `xmlIOHTTPOpenW':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1405: undefined reference to `deflateInit2_'
.//libxml2.a(xmlIO.o)(.text+0x2230):/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1420: undefined reference to `crc32'
.//libxml2.a(xmlIO.o)(.text+0x288c): In function `xmlIOHTTPWrite':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1522: undefined reference to `deflate'
.//libxml2.a(xmlIO.o)(.text+0x28b0):/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/xmlIO.c:1534: undefined reference to `crc32'
.//libxml2.a(nanohttp.o)(.text+0x4dc): In function `xmlNanoHTTPFreeCtxt':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/nanohttp.c:422: undefined reference to `inflateEnd'
.//libxml2.a(nanohttp.o)(.text+0x1068): In function `xmlNanoHTTPRead':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/nanohttp.c:1214: undefined reference to `inflate'
.//libxml2.a(nanohttp.o)(.text+0x1a98): In function `xmlNanoHTTPMethodRedir':
/home/lixin/WORK/XML/CreateXmlStaticLib/libxml2-2.6.30/nanohttp.c:782: undefined reference to `inflateInit2_'
collect2: ld returned 1 exit status
是什么原因呢??该如何解决呢??各位帮忙看看。
我用动态库链接时没有问题。
------解决方案--------------------
HAVE_ZLIB_H 定义一般在config.h用./configure生成的
configure 时加上 --without-zlib参数
当然也可以安装zlib然后链接程序时加上