If you are going to compile a C program with pthread.h in LINUX using GCC or G++ you will have to use –lpthread option after the compile command.
gcc xyz.c -o xyz -lpthread
Here,
gcc is compiler command (compiler name)
xyz.c is a source file name.
-o is an option to create objcect file.
xyz is the name of object (binary) file.
-lpthread is an option for pthread.h
for more details here is the link conatining complete article on it.
Compiling C program with pthread.h in Linux.
pthread
库不是 Linux 默认的库,有些 Library 默认使用pthread
但是在介绍的时候没有说明,导致编译时出错。-lpthread
和-pthread
两种写法好像都可以。