在編譯中要加 -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