这是我的链接命令行:GCC报告未定义的引用与现有符号
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开始)。
您不需要与构建系统对抗:复制并粘贴调用链接器的行并按需要进行编辑。先尝试一下,看看删除重复是否有帮助。 – Hbcdev 2012-08-02 17:52:09
我做过同样的事情... – lvella 2012-08-02 17:56:18
OGRE库中的这些符号标记为* local *(小写't')。编译库的方式可能存在问题,或者您可能试图使用不应在用户代码中使用的符号。另外,我不确定是否在命令行中的.so之前不应该有'-l'... – 2012-08-02 18:21:26