线程编译(undefined reference to ‘pthread_create‘,undefined reference to ‘pthread_join‘,collect2: error:)
·
Linux线程编译时,出现以下报错:
undefined reference to 'pthread_create'
undefined reference to 'pthread_join'
collect2: error: ld returned 1 exit status

问题原因:
这个问题其实是库文件不齐全导致的,pthread 库不是 Linux 系统默认的库,需要在编译时手动链接线程库
解决方法:
gcc test.c -o test -lpthread
gcc test.c -o test -pthread
更多推荐
所有评论(0)