gcc未定义库之间的引用

时间:2013-03-02 15:18:38

标签: gcc linker static-libraries nm

在链接时,我得到以下内容:

libMain.a(Object.o): In function `Object': 
Object.cpp(44): undefined reference to `Transform::MakeIdentity()'

使用nm --defined-only libSystem.a

绝对可以看出这一点
Transform.o:
00000000 T Transform::MakeIdentity()

正在正确输入libSystem.a和libMain.a。链接器命令行选项:

  

-o“Game.so”-shared -Wl,-z,noexecstack“-lstdc ++”“ - slupc ++”“ - lgnustl_static”“ - lgcc”“libSystem.a”“libMain.a”-nostdlib -l“ c“-l”m“-l”log“-l”gcc“-Wl,-soname,”libGame“-Wl, - no-undefined

1 个答案:

答案 0 :(得分:4)

链接静态库的顺序很重要。有关详细讨论,请参阅Why does the order in which libraries are linked sometimes cause errors in GCC?