Ubuntu16.04编译程序报错“undefined reference to `pthread_create‘”解决方法

问题描述

在Ubuntu16.04使用gcc编译程序失败,主体错误信息为“undefined reference to `pthread_create”:
在这里插入图片描述

解决方法
(1)检查源码,在调用pthread_create函数,是否引用了头文件 #include<pthread.h>,若没有则加上。
(2)由于pthread不是Linux系统标准库,因此在编译的时候需要把 lpthread 加上。
gcc module.c -o module -lpthread
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/locahuang/article/details/107818013