pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。
源文件,不要忘了加上头文件#include<pthread.h>
在编译中要加 -lpthread参数
#gcc test.c -o thread -lpthread
undefined reference to 'pthread_create'
最新推荐文章于 2021-04-24 15:26:07 发布