在开发多线程的程序时,有时结果出现如下错误:
undefined reference to 'pthread_create'
undefined reference to 'pthread_join'
问题原因:
pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。
问题解决:
在编译中要加 -lpthread参数
gcc -o thread thread.c -lpthread
thread.c为你些的源文件,不要忘了加上头文件#include<pthread.h>
undefined reference to 'pthread_create'
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
undefined reference to 'pthread_create'问题解决
eference to 'p
reference linux ubuntu 程序开发 编程 -
undefined reference to 'pthread_create'问题解决方法
在GUN/linux下我们使用 #include 时会出现下面的错误:undefined reference to 'pthread_create'undefined reference to
pthread_create reference linux 编程 reference linux thre -
怎样彻底解决"undefined reference to `pthread_create'"问题
在编写pthread有关的程序时,编译
reference gcc 配置文件 环境变量