2
我想在msys上使用g ++编译一个简单的opengl程序。令我惊讶的链接器抱怨未定义引用:奇怪的g ++链接行为取决于参数顺序
$ g++ -mwindows -lopengl32 glut_md2.cpp
C:\Users\...\cceQtYAy.o:glut_md2.cpp:(.text+0x67a): undefined reference to `[email protected]'
C:\Users\...\cceQtYAy.o:glut_md2.cpp:(.text+0x696): undefined reference to `[email protected]'
....
Google上搜寻了一段时间后,我发现这个问题是在G ++参数命令:
$ g++ glut_md2.cpp -mwindows -lopengl32
--- all ok! ---
有趣的是,正确的说法订单在g ++中是第一个例子。那就是:
$ g++ --help
Usage: g++.exe [options] file...
....
我错过了什么吗?为什么在之后移动选项文件参数使编译成功?我在linux上本地编译时从来没有遇到过这个问题......
奇怪。我认为g ++应该以任何方式将链接选项传递给链接器,因为它在上面的示例中非常明确。巫术魔法...... – gundra