问题描述
在Ubuntu16.04使用gcc编译程序失败,主体错误信息为“undefined reference to `pthread_create”:
解决方法
(1)检查源码,在调用pthread_create函数,是否引用了头文件 #include<pthread.h>,若没有则加上。
(2)由于pthread不是Linux系统标准库,因此在编译的时候需要把 lpthread 加上。
gcc module.c -o module -lpthread
问题描述
在Ubuntu16.04使用gcc编译程序失败,主体错误信息为“undefined reference to `pthread_create”:
解决方法
(1)检查源码,在调用pthread_create函数,是否引用了头文件 #include<pthread.h>,若没有则加上。
(2)由于pthread不是Linux系统标准库,因此在编译的时候需要把 lpthread 加上。
gcc module.c -o module -lpthread