码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-06-05 06:08:23      阅读:140      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!