pthread库不是Linux系统默认的库,连接时需要使用库libpthread.a,在编译中要加-lpthread
[kou@localhost practive]$ gcc creat.c
/tmp/ccPULtaF.o:在函数‘main’中:
creat.c:(.text+0x58):对‘pthread_create’未定义的引用
collect2: 错误:ld 返回 1
[kou@localhost practive]$ gcc creat.c -lpthread
本文介绍了解决在GCC编译过程中遇到的pthread_create函数未定义引用的问题。通过添加-lpthread选项到编译命令中,成功链接了libpthread库,使得程序能够正确编译。
pthread库不是Linux系统默认的库,连接时需要使用库libpthread.a,在编译中要加-lpthread
[kou@localhost practive]$ gcc creat.c
/tmp/ccPULtaF.o:在函数‘main’中:
creat.c:(.text+0x58):对‘pthread_create’未定义的引用
collect2: 错误:ld 返回 1
[kou@localhost practive]$ gcc creat.c -lpthread
413
2655

被折叠的 条评论
为什么被折叠?