未定义对gzdopen,gzclose,gzread的引用 [英] undefined reference to gzdopen, gzclose, gzread
问题描述
我已经编译并安装了2.2.7.2版的libxml.编译时出现以下错误:Makefile:755:目标"install-data-local"的配方失败.但是正确生成了lib文件(libxml2.a和libxml2.so).我想在C项目中使用libxml2,所以我编辑了makefile以集成lib文件(libxml2.a和libxml2.so).问题是,当我编译项目时,出现以下错误:/libxml2.a(xmlIO.o):在函数 xmlGzfileRead'中:未定义对
gzdopen的引用"/libxml2.a(xmlIO.o):在函数 xmlGzfileRead'中:对
gzclose的未定义引用/libxml2.a(xmlIO.o):在函数 xmlGzfileRead'中:未定义对
gzread的引用"...等等看来我必须安装zlib库才能解决此链接器错误.我安装了zlib库并编辑了LD_LIBRARY_PATH,以便将zlib库添加到路径.我重新编译了项目,但仍然始终遇到相同的链接器错误.
I have compiled and installed the 2.2.7.2 version of libxml. While compiling, I have this error: Makefile:755: recipe for target 'install-data-local' failed. But the lib files are correctly generated (libxml2.a and libxml2.so).
I'd like to use libxml2 in a C project so I edited my makefiles in order to integrate lib files (libxml2.a and libxml2.so).
The problem is that when I compile my project I get the followings errors:
/libxml2.a(xmlIO.o): In function xmlGzfileRead': undefined reference to
gzdopen'
/libxml2.a(xmlIO.o): In function xmlGzfileRead': undefined reference to
gzclose'
/libxml2.a(xmlIO.o): In function xmlGzfileRead': undefined reference to
gzread'
...etc
It seems that I have to install the zlib library in order to resolve this linker errors. I installed the zlib library and edited the LD_LIBRARY_PATH in order to add the path where are the zlib libraries.
I recompiled my project, but I still always having the same linker errors.
请您帮助我解决那些链接器错误.
Would you please help me to resolve those linker errors.
致谢.
推荐答案
请参见 libxml2常见问题解答:
使用libxml2编译或链接程序时遇到问题
通常,问题出在以下事实:编译器未获得正确的编译或链接标志.作为libxml2常规安装过程的一部分,安装了一个小的shell脚本xml2-config,该脚本提供了这些标志.使用
Usually the problem comes from the fact that the compiler doesn't get the right compilation or linking flags. There is a small shell script xml2-config which is installed as part of libxml2 usual install process which provides those flags. Use
xml2-config --cflags
获取编译标志和
xml2-config --libs
以获取链接器标志.通常,这是直接通过Makefile通过以下方式完成的:
to get the linker flags. Usually this is done directly from the Makefile as:
CFLAGS=`xml2-config --cflags`
LIBS=`xml2-config --libs`
在当前系统上, xml2-config --libs
的输出为
On my current system, the output from xml2-config --libs
is
-lxml2 -lz -lpthread -licucore -lm
这篇关于未定义对gzdopen,gzclose,gzread的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!