gpt4 book ai didi

c++ - GCC 报告对现有符号的 undefined reference

转载 作者:太空宇宙 更新时间:2023-11-04 05:36:12 26 4
gpt4 key购买 nike

这是我的链接命令行:

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

我知道有一些重复,但我认为这应该没有什么害处,而且我不想在知道问题所在之前与构建系统进行斗争。

问题是我得到了一些 undefined reference :

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.soPlugin_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 的所有内容)。

最佳答案

链接器命令中库的顺序很重要:http://www.network-theory.co.uk/docs/gccintro/gccintro_18.html

要做的第一件事是将 -o verdox 放在命令末尾。我以前也遇到过这个问题...然后看看是否还有任何错误。

关于c++ - GCC 报告对现有符号的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11783000/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com