这是我的链接命令行:
g++ -o verdox src/AIFactory.o src/AnimatedMesh.o src/BalanceStone.o src/Camera.o \
src/Card.o src/Caterpillar.o src/Character.o src/Collectable.o src/Concave.o \
src/Configuration.o src/Dynamic.o src/DynBall.o src/Enemy.o src/FixedLight.o \
src/FuzzyState.o src/Game.o src/GameInput.o src/GameUnit.o src/HUD.o src/Level.o \
src/LogicAttributes.o src/MainCharacter.o src/Main.o src/Menu.o src/MenuInput.o \
src/MeshStrider.o src/Object.o src/ObjectFactory.o src/OgreDebugDrawer.o \
src/OgreMusic.o src/OgreSoundEffect.o src/Projectile.o src/Scenery.o src/Shape.o \
src/SoftBody.o src/Trigger.o src/Utils.o src/Verdox.o src/Wasp.o src/World.o \
UFUG/libufug.a TinyXML/libtinyxml.a -L[...](lots of library dirs) \
-lboost_thread-mt -logg -lvorbis -lvorbisfile -lConvexDecomposition \
-lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath \
-lOgreMain -lpthread /usr/local/lib/OGRE/Plugin_OctreeZone.so \
/usr/local/lib/OGRE/Plugin_PCZSceneManager.so -Wl,-rpath,/usr/local/lib/OGRE \
-L/usr/local/lib -lOgreMain -lpthread -L/usr/local/lib -lCEGUIBase \
-L/usr/local/lib -lCEGUIOgreRenderer -lOgreMain -lpthread -lCEGUIBase -lsigc-2.0 \
-lopenal -lOIS
我知道有一些重复,但我认为它应该没有坏处,我不想在知道错误之前与构建系统作斗争。
问题是我得到了一些未定义的引用:
src/Game.o: In function `Game':
/home/lucas/src/ufugames/verdox/src/Game.cpp:64: undefined reference to `Ogre::PCZPlugin::PCZPlugin()'
/home/lucas/src/ufugames/verdox/src/Game.cpp:64: undefined reference to `Ogre::OctreeZonePlugin::OctreeZonePlugin()'
src/Game.o: In function `~PCZPlugin':
/home/lucas/src/ufugames/ogre_src_v1-8-0/PlugIns/PCZSceneManager/include/OgrePCZPlugin.h:49: undefined reference to `vtable for Ogre::PCZPlugin'
src/Game.o: In function `~OctreeZonePlugin':
/home/lucas/src/ufugames/ogre_src_v1-8-0/PlugIns/OctreeZone/include/OgreOctreeZonePlugin.h:47: undefined reference to `vtable for Ogre::OctreeZonePlugin'
collect2: ld returned 1 exit status
但是Plugin_OctreeZone.so
和Plugin_PCZSceneManager.so
内找到了所有丢失的符号:
$ nm -C /usr/local/lib/OGRE/Plugin_PCZSceneManager.so | grep "Ogre::PCZPlugin::PCZPlugin()"
00029440 t Ogre::PCZPlugin::PCZPlugin()
00029440 t Ogre::PCZPlugin::PCZPlugin()
$ nm -C /usr/local/lib/OGRE/Plugin_PCZSceneManager.so | grep "vtable for Ogre::PCZPlugin"
00046e20 d vtable for Ogre::PCZPlugin
$ nm -C /usr/local/lib/OGRE/Plugin_OctreeZone.so | grep "Ogre::OctreeZonePlugin::OctreeZonePlugin()"
0000c350 t Ogre::OctreeZonePlugin::OctreeZonePlugin()
0000c350 t Ogre::OctreeZonePlugin::OctreeZonePlugin()
$ nm -C /usr/local/lib/OGRE/Plugin_OctreeZone.so | grep "vtable for Ogre::OctreeZonePlugin"
0000fe20 d vtable for Ogre::OctreeZonePlugin
那么,为什么链接失败?我使用的是GNU ld 2.21.53.20110810和GCC 4.6.1(Ubuntu 11.10中的所有内容)。
答案 0 :(得分:-1)
库顺序在链接器命令中很重要:http://www.network-theory.co.uk/docs/gccintro/gccintro_18.html
首先要做的是将-o verdox
放在命令的末尾。我之前遇到过这个问题......然后看看是否还有错误。