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
本文详细解释了在Linux环境下,使用gcc编译时遇到的pthread库未定义引用错误。指出pthread并非系统默认库,需链接libpthread.a,并在编译命令末尾加入-lpthread参数。通过实际案例演示正确配置方法。
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

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