这是我的链接命令行:
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
and中找到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)。