1、gcc用于编译C程序,cpp程序需要用g++
2、因为pthread并非Linux系统的默认库,而是POSIX线程库。在Linux中将其作为一个库来使用,因此加上 -lpthread(或-pthread)以显式链接该库。
[ zjy@livedvd ~]$ gcc -o thread thread.c -pthread
[zjy@livedvd ~]$ gcc -o thread thread.c -lpthread
1、gcc用于编译C程序,cpp程序需要用g++
2、因为pthread并非Linux系统的默认库,而是POSIX线程库。在Linux中将其作为一个库来使用,因此加上 -lpthread(或-pthread)以显式链接该库。
[ zjy@livedvd ~]$ gcc -o thread thread.c -pthread
[zjy@livedvd ~]$ gcc -o thread thread.c -lpthread