make时提示pthread的错误,在线等

xxjnetwork 2012-04-15 02:00:57
错误如下
gtm_txn.o: In function `GTM_BeginTransactionMulti':
gtm_txn.c:(.text+0xe09): undefined reference to `pthread_getspecific'
gtm_txn.o: In function `GTM_GetGIDData':
gtm_txn.c:(.text+0x15af): undefined reference to `pthread_getspecific'
gtm_txn.o: In function `ProcessBeginTransactionCommand':
gtm_txn.c:(.text+0x16fa): undefined reference to `pthread_getspecific'
gtm_txn.o: In function `ProcessBeginTransactionGetGXIDCommand':
gtm_txn.c:(.text+0x187b): undefined reference to `pthread_getspecific'
gtm_txn.c:(.text+0x1a49): undefined reference to `pthread_getspecific'
gtm_txn.o:gtm_txn.c:(.text+0x1a6a): more undefined references to `pthread_getspecific' follow
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockAcquire':
gtm_lock.c:(.text+0x25): undefined reference to `pthread_rwlock_wrlock'
gtm_lock.c:(.text+0x36): undefined reference to `pthread_rwlock_rdlock'
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockRelease':
gtm_lock.c:(.text+0x8b): undefined reference to `pthread_rwlock_unlock'
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockInit':
gtm_lock.c:(.text+0xb4): undefined reference to `pthread_rwlock_init'
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockDestroy':
gtm_lock.c:(.text+0xce): undefined reference to `pthread_rwlock_destroy'
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockConditionalAcquire':
gtm_lock.c:(.text+0xf9): undefined reference to `pthread_rwlock_trywrlock'
gtm_lock.c:(.text+0x10a): undefined reference to `pthread_rwlock_tryrdlock'
../common/libgtm.a(gtm_lock.o): In function `GTM_MutexLockConditionalAcquire':
gtm_lock.c:(.text+0x1d6): undefined reference to `pthread_mutex_trylock'
../common/libgtm.a(gtm_list.o): In function `new_list':
gtm_list.c:(.text+0x52): undefined reference to `pthread_getspecific'
gtm_list.c:(.text+0x83): undefined reference to `pthread_getspecific'
../common/libgtm.a(gtm_list.o): In function `new_head_cell':
gtm_list.c:(.text+0xdc): undefined reference to `pthread_getspecific'
../common/libgtm.a(gtm_list.o): In function `new_tail_cell':
gtm_list.c:(.text+0x13a): undefined reference to `pthread_getspecific'
../common/libgtm.a(gtm_list.o): In function `add_new_cell':
gtm_list.c:(.text+0x1f0): undefined reference to `pthread_getspecific'
../common/libgtm.a(gtm_list.o):gtm_list.c:(.text+0xc0e): more undefined references to `pthread_getspecific' follow



我知道是pthread的问题,问题是我在ubuntu已经安装这个库了,用man -k也可以查看到pthread_getspecific等这些方法,
xjxia@xjxia:~/postgres-xc$ ls -la /usr/lib/libboost_thread.so
lrwxrwxrwx 1 root root 25 2011-06-04 05:30 /usr/lib/libboost_thread.so -> libboost_thread.so.1.46.1
这个也是有的
xjxia@xjxia:~/postgres-xc$ whereis pthread
pthread: /usr/include/pthread.h



为什么make还是报错,求大神帮忙,在线等
...全文
2590 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
luciferisnotsatan 2012-04-16
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]

引用 3 楼 的回复:

引用 1 楼 的回复:

是不是没连接库的原因。-lpthread -lboost_thread



make -lpthread -lboost_thread这么来了还是报这个错误,难道是pthread,或者boost_thread安装有问题吗






问题已经解决了,不是库的问题。而是GCC版本的问题,把报错地方makefil……
[/Quote]
没有过ubuntu,不过sles和rhel里都是要-l的。
xxjnetwork 2012-04-16
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

引用 1 楼 的回复:

是不是没连接库的原因。-lpthread -lboost_thread



make -lpthread -lboost_thread这么来了还是报这个错误,难道是pthread,或者boost_thread安装有问题吗
[/Quote]





问题已经解决了,不是库的问题。而是GCC版本的问题,把报错地方makefile的-lpthread都改为-pthread就可以了。我老大跟我说是gcc版本导致的(我的是ubuntu),难道ubuntu的gcc不需要-l参数吗,其他平台可以省略吗
xxjnetwork 2012-04-15
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

不是,是写在make的命令里
cc test.c -o test -lpthread -lboost_thread
[/Quote]

gtm_snap.c: 在函数‘ProcessGetSnapshotCommand’中:
gtm_snap.c:285:7: 警告: 变量‘canbe_grouped’被设定但未被使用 [-Wunused-but-set-variable]
gcc -DPGXC -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -I../../../src/include -D_GNU_SOURCE -c -o gtm_time.o gtm_time.c
gcc -DPGXC -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -I../../../src/include -D_GNU_SOURCE -c -o gtm_standby.o gtm_standby.c
gcc -DPGXC -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -I../../../src/include -D_GNU_SOURCE -c -o gtm_opt.o gtm_opt.c
gcc -DPGXC -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -L../../../common -L../../../libpq -lpthread main.o gtm_thread.o gtm_txn.o gtm_seq.o gtm_snap.o gtm_time.o gtm_standby.o gtm_opt.o ../libpq/libpqcomm.a ../path/libgtmpath.a ../recovery/libgtmrecovery.a ../client/libgtmclient.a ../common/libgtm.a ../../port/libpgport.a -o gtm
main.o: In function `MainThreadInit':
main.c:(.text+0x13): undefined reference to `pthread_key_create'
main.c:(.text+0x126): undefined reference to `pthread_setspecific'
main.o: In function `BaseInit':
main.c:(.text+0x1ab): undefined reference to `pthread_getspecific'
main.o: In function `GTM_ThreadMain':
main.c:(.text+0x14d0): undefined reference to `pthread_getspecific'
main.c:(.text+0x14e0): undefined reference to `pthread_getspecific'
main.c:(.text+0x177c): undefined reference to `pthread_getspecific'
main.c:(.text+0x179a): undefined reference to `pthread_getspecific'
main.o:main.c:(.text+0x17b2): more undefined references to `pthread_getspecific' follow
gtm_thread.o: In function `GTM_ThreadCreate':
gtm_thread.c:(.text+0x465): undefined reference to `pthread_create'
gtm_thread.o: In function `GTM_ThreadJoin':
gtm_thread.c:(.text+0x4e6): undefined reference to `pthread_join'
gtm_thread.o: In function `GTM_ThreadCleanup':
gtm_thread.c:(.text+0x682): undefined reference to `pthread_setspecific'
gtm_thread.o: In function `GTM_ThreadMainWrapper':
gtm_thread.c:(.text+0x6b0): undefined reference to `pthread_detach'
gtm_thread.c:(.text+0x6c4): undefined reference to `pthread_setspecific'
gtm_thread.c:(.text+0x6d1): undefined reference to `pthread_getspecific'
gtm_thread.c:(.text+0x739): undefined reference to `__pthread_register_cancel'
gtm_thread.c:(.text+0x759): undefined reference to `__pthread_unregister_cancel'
gtm_txn.o: In function `GTM_BeginTransactionMulti':
gtm_txn.c:(.text+0xe09): undefined reference to `pthread_getspecific'
gtm_txn.o: In function `GTM_GetGIDData':
gtm_txn.c:(.text+0x15af): undefined reference to `pthread_getspecific'
gtm_txn.o: In function `ProcessBeginTransactionCommand':
gtm_txn.c:(.text+0x16fa): undefined reference to `pthread_getspecific'
gtm_txn.o: In function `ProcessBeginTransactionGetGXIDCommand':
gtm_txn.c:(.text+0x187b): undefined reference to `pthread_getspecific'
gtm_txn.c:(.text+0x1a49): undefined reference to `pthread_getspecific'
gtm_txn.o:gtm_txn.c:(.text+0x1a6a): more undefined references to `pthread_getspecific' follow
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockAcquire':
gtm_lock.c:(.text+0x25): undefined reference to `pthread_rwlock_wrlock'
gtm_lock.c:(.text+0x36): undefined reference to `pthread_rwlock_rdlock'
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockRelease':
gtm_lock.c:(.text+0x8b): undefined reference to `pthread_rwlock_unlock'
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockInit':
gtm_lock.c:(.text+0xb4): undefined reference to `pthread_rwlock_init'
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockDestroy':
gtm_lock.c:(.text+0xce): undefined reference to `pthread_rwlock_destroy'
../common/libgtm.a(gtm_lock.o): In function `GTM_RWLockConditionalAcquire':
gtm_lock.c:(.text+0xf9): undefined reference to `pthread_rwlock_trywrlock'
gtm_lock.c:(.text+0x10a): undefined reference to `pthread_rwlock_tryrdlock'
../common/libgtm.a(gtm_lock.o): In function `GTM_MutexLockConditionalAcquire':
gtm_lock.c:(.text+0x1d6): undefined reference to `pthread_mutex_trylock'
../common/libgtm.a(gtm_list.o): In function `new_list':
gtm_list.c:(.text+0x52): undefined reference to `pthread_getspecific'
gtm_list.c:(.text+0x83): undefined reference to `pthread_getspecific'
../common/libgtm.a(gtm_list.o): In function `new_head_cell':
gtm_list.c:(.text+0xdc): undefined reference to `pthread_getspecific'
../common/libgtm.a(gtm_list.o): In function `new_tail_cell':
gtm_list.c:(.text+0x13a): undefined reference to `pthread_getspecific'
../common/libgtm.a(gtm_list.o): In function `add_new_cell':
gtm_list.c:(.text+0x1f0): undefined reference to `pthread_getspecific'
../common/libgtm.a(gtm_list.o):gtm_list.c:(.text+0xc0e): more undefined references to `pthread_getspecific' follow


一个项目里面有很多makefile,你看看我这错误该写在哪个makefile,而且我觉得不是makefile的问题,因为在AS3(红旗,跟redhat差不多)上面编译是没问题的,我这错误是在ubuntu上面报出来的
sundayX 2012-04-15
  • 打赏
  • 举报
回复
不是,是写在make的命令里
cc test.c -o test -lpthread -lboost_thread
xxjnetwork 2012-04-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

是不是没连接库的原因。-lpthread -lboost_thread
[/Quote]


make -lpthread -lboost_thread这么来了还是报这个错误,难道是pthread,或者boost_thread安装有问题吗
xxjnetwork 2012-04-15
  • 打赏
  • 举报
回复
我猜想也是,但是我对make不是很熟悉,请问怎么连接,直接make时后面跟这两个参数吗
sundayX 2012-04-15
  • 打赏
  • 举报
回复
是不是没连接库的原因。-lpthread -lboost_thread

70,004

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧