问题:ubuntu环境在编译pthread_函数相关代码时,报如下错误:**
zhuqingping@ubuntu:~/Study/C/pthread$ gcc -o child_thread child_thread.c
/tmp/ccXx2krL.o:在函数‘main’中:
child_thread.c:(.text+0x5a):对‘pthread_create’未定义的引用
child_thread.c:(.text+0x91):对‘pthread_join’未定义的引用
collect2: error: ld returned 1 exit status
解决办法:在编译时明确指定链接库,在编译的最后添加 -lpthread即可