我有一个在SuseLinux和Debian中成功编译的项目,但它在Ubuntu中失败了。
Ubuntu中的错误消息是
undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
[ERROR] /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
我理解错误的产生是因为在链接时未声明-lpthread
。该项目链接到rt
,crypto
和其他系统库,但未明确声明pthread
。
我不明白为什么链接过程在Ubuntu中失败而在其他Linux系统中失败。
系统中的gcc版本是:
gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2)
gcc version 4.7.2 (Debian 4.7.2-5)
链接错误是否可以由gcc 5.x生成?