pthread.h 的 undefined reference to `pthread_create'

在编译中要加 -lpthread或-pthread参数(不一样版本的gcc可能不同,man gcc能够查阅对应参数)。编译

例如:在加了头文件#include <pthread.h>以后执行 pthread.c文件,须要使用以下命令:thread

    gcc -lpthread -o thread thread.cgcc

gc

    gcc -pthread -o thread thread.c文件

这种状况相似于<math.h>的使用,需在编译时加 -m 参数。math

相关文章
相关标签/搜索