链接libresolv时的未定义引用

时间:2010-10-20 15:28:17

标签: c++ autotools glibc libtool

我有一个项目,它是一个链接libresolv的库, 它适用于最近的发行版:Ubuntu 10.x Fedora 13,Mandriva 2010.1但在Centos 5.x上我收到以下错误

安装的glibc是:glibc-2.5-18.el5_1.1

g++ -DHAVE_CONFIG_H -I.  -I./include -I/usr/include/postgresql  -O3
-ansi   -Wall -Wno-deprecated  -D_FORTIFY_SOURCE=0 -MT testUpLog.o -MD
-MP -MF .deps/testUpLog.Tpo -c -o testUpLog.o testUpLog.cc
mv -f .deps/testUpLog.Tpo .deps/testUpLog.Po
/bin/sh ./libtool --tag=CXX   --mode=link g++  -O3 -ansi   -Wall
-Wno-deprecated  -D_FORTIFY_SOURCE=0  -L/usr/lib64 -L/lib64
-L/usr/lib64/mysql -o testUpLog testUpLog.o libUpTools.la -lpq
-lmysqlclient -lssl -lpthread
libtool: link: g++ -O3 -ansi -Wall -Wno-deprecated -D_FORTIFY_SOURCE=0
-o .libs/testUpLog testUpLog.o  -L/usr/lib64 -L/lib64
-L/usr/lib64/mysql ./.libs/libUpTools.so -lpq -lmysqlclient -lssl
-lpthread
./.libs/libUpTools.so: undefined reference to `__ns_name_uncompress'
./.libs/libUpTools.so: undefined reference to `__ns_initparse'
./.libs/libUpTools.so: undefined reference to `__ns_parserr'
collect2: ld returned 1 exit status
make[1]: *** [testUpLog] Error 1
make[1]: Leaving directory `/tmp/UpTools-8.5.3'
make: *** [check-am] Error 2

library.la文件包含:

dlname='libUpTools.so.0'
library_names='libUpTools.so.0.0.0 libUpTools.so.0 libUpTools.so'
old_library='libUpTools.a'
inherited_linker_flags=''
dependency_libs=' -L/usr/lib64 -L/lib64 -L/usr/lib64/mysql -lpq
-lmysqlclient -lssl -lpthread'
weak_library_names=''
current=0
age=0
revision=0
installed=no
shouldnotlink=no
dlopen=''
dlpreopen=''
libdir='/usr/lib'

您可以在

上阅读configure.ac.

http://pastebin.com/hs5q21Rq

提前致谢

1 个答案:

答案 0 :(得分:2)

如果libUpTools使用lib libresolv函数,你需要这样说:

libUpTools_la_LIBADD = -lresolv(当然-lresolv可能会被configure等确定的变量所取代。)

这样,-lresolv最终会在.la文件中以及.so文件中(如果你选择构建它),你可以运行ldd进行验证。