OSTEP GCC 编译报错 undefined reference to `pthread_create'

Issue

[root@host1 Code-Intro]# gcc -o cpu cpu.c -Wall
/tmp/ccG1P1Rf.o: In function `Pthread_create':
cpu.c:(.text+0xce): undefined reference to `pthread_create'
/tmp/ccG1P1Rf.o: In function `Pthread_join':
cpu.c:(.text+0x11a): undefined reference to `pthread_join'
collect2: ld returned 1 exit status

Resolution

[root@host1 Code-Intro]# gcc -o cpu cpu.c -Wall -lpthread
(add "-lpthread" option.)