首页 > 其他 > 详细

undefined reference to `pthread_create' collect2: ld returned 1 exit status

时间:2015-06-05 06:08:21      阅读:304      评论:0      收藏:0      [点我收藏+]

Linux下编译多线程程序遇到错误:

undefined reference to `pthread_createcollect2: ld returned 1 exit status

原因是系统无法找到pthread_create函数。也就是说编译器在link得时候找不到其中的一个使用库的函数。

解决办法如下:

For Linux the correct command is:

gcc -pthread xxx.c

In general, libraries should follow sources and objects on command line, and -lpthread is not an "option", it‘s a library specification. On a system with only libpthread.a installed,

gcc -lpthread xxx.c//By this, ld will try to link libpthread.so

will fail to link.

undefined reference to `pthread_create' collect2: ld returned 1 exit status

原文:http://www.cnblogs.com/bukekangli/p/4553490.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!