标签:
Linux下编译多线程程序遇到错误:
undefined reference to `pthread_create‘ collect2: 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