且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Linux 中对 pthread_create 的未定义引用

更新时间:2022-03-24 23:13:33

对于 Linux,正确的命令是:

For Linux the correct command is:

gcc -pthread -o term term.c

一般来说,库应该遵循命令行上的源和对象,而 -lpthread 不是一个选项",它是一个库规范.在仅安装了 libpthread.a 的系统上,

In general, libraries should follow sources and objects on command line, and -lpthread is not an "option", it's a library specification. On a system with only libpthread.a installed,

gcc -lpthread ...

将无法链接.