线程pthread程序编译时库文件的添加-L/usr/lib/-lpthread

20 篇文章 0 订阅
编译线程程序时的错误解决:
xjtu129@xjtu129-desktop:~/wz$ gcc testThread.c
/tmp/ccKXccVy.o: In function `main':
testThread.c:(.text+0x2b): undefined reference to `sem_init'
testThread.c:(.text+0x6f): undefined reference to `pthread_create'
testThread.c:(.text+0x9d): undefined reference to `sem_post'
testThread.c:(.text+0xef): undefined reference to `pthread_join'
testThread.c:(.text+0x10a): undefined reference to `sem_destroy'
/tmp/ccKXccVy.o: In function `thread_function':
testThread.c:(.text+0x12a): undefined reference to `sem_wait'
testThread.c:(.text+0x16a): undefined reference to `sem_wait'
collect2: ld 返回 1
这样就可以了:
gcc testThread.c -L/usr/lib/ -lpthread
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值