您的位置:首页 > 其它

Ubuntu下编译程序是出现pthread_create未定义错误

2014-02-10 17:06 465 查看
gcc -c node_list.c -o node_list.o
gcc -lpthread sim.o cli.o list.o node_list.o -o sim.exe
sim.o: In function `sim_add_node':
sim.c:(.text+0xa55): undefined reference to `pthread_create'
sim.c:(.text+0xa8a): undefined reference to `pthread_create'
sim.o: In function `sim_kill_nodes':
sim.c:(.text+0xb5a): undefined reference to `pthread_kill'
cli.o: In function `kill_node':
cli.c:(.text+0x4ec): undefined reference to `pthread_kill'
cli.c:(.text+0x512): undefined reference to `pthread_kill'
collect2: ld returned 1 exit status
make: *** [sim.exe] Error 1


百思不得其姐。。。

最后在这里看到了,泪流满面啊。(-l包含库指令的位置要在最后!!)



换了位置之后

gcc sim.o cli.o list.o node_list.o -o sim.exe -lpthread
cp sim.exe ../test/test_sim


可以了。

实际上,这可能不是这么简单地将该指令放在最后这么简单。这或许是涉及到lpthread和pthread的用法问题,请参考网友的文章。

http://chaoslawful.iteye.com/blog/568602
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐