与pthread链接的C_icap错误

时间:2012-09-18 10:33:21

标签: c ubuntu linker pthreads glibc

我想在Ubuntu 11上安装c_icap并遇到以下错误。

make[2]: Entering directory `/home/madmin/milkyway/sol/server/3rdparty/c_icap-0.1.7/tests'
/bin/bash ../libtool --tag=CC   --mode=link gcc -I../include/ -D_REENTRANT -g -O2 -Wall -rdynamic -rpath /usr/local/c_icap/lib   -o test_cache test_cache.o  **-lpthread** ../libicapapi.la  -ldl
libtool: link: gcc -I../include/ -D_REENTRANT -g -O2 -Wall -rdynamic -o .libs/test_cache test_cache.o  **-lpthread** ../.libs/libicapapi.so -ldl -Wl,-rpath -Wl,/usr/local/c_icap/lib
../.libs/libicapapi.so: undefined reference to `pthread_rwlock_rdlock'
../.libs/libicapapi.so: undefined reference to `pthread_rwlock_wrlock'
../.libs/libicapapi.so: undefined reference to `pthread_rwlock_unlock'
collect2: ld returned 1 exit status

不确定是什么问题,因为我看到了 libicap.so 的objdump并得到了这个

0000000000000000         *UND*  0000000000000000              pthread_rwlock_rdlock
0000000000000000       F *UND*  0000000000000000    pthread_mutex_destroy@@GLIBC_2.2.5
0000000000000000         *UND*  0000000000000000              pthread_rwlock_wrlock
0000000000000000       F *UND*  0000000000000000   pthread_mutex_unlock@@GLIBC_2.2.5
0000000000000000         *UND*  0000000000000000              pthread_rwlock_unlock

这表明pthread lib没有丢失,因为在objdump中正确解析了pthread_mutex符号。还-lpthread标志也存在。

在Makefile中我有

THREADS_LDADD = -lpthread
c_icap_LDADD = -lpthread libicapapi.la  -ldl

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

改为使用-pthread进行编译。

这将包括所需的一切。