這是我的鏈接命令行: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