我是编程和编译C ++的初学者。我目前正在尝试使用g ++编译器和makefile在 OSX(10.10)上构建非常基本的 OGRE 应用程序。我的makefile基于cleversoap's github repository上提供的文件。我也在使用SDK for OSX的预构建版本。
当我第一次尝试从OGRE 3D网站构建tutorial framework时,我最终遇到了与Ogre对象和函数定义相关的多个链接错误。我编辑了源文件,只留下了几行代码。
#include <OgreRoot.h>
#include <OgreCamera.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreLogManager.h>
#include <OgreViewport.h>
#include <OgreEntity.h>
#include <OgreWindowEventUtilities.h>
#include <OgrePlugin.h>
int main() {
Ogre::Root* mRoot;
mRoot = new Ogre::Root("", "", "LowLevelOgre.log");
delete mRoot;
}
我的makefile生成的编译命令如下所示:
g++ LowLevelOgre.cpp -o OgreMake.app/Contents/MacOS/OgreMake -arch i386 -I/Developer/SDKs/OgreSDK/include/OGRE -I/Developer/SDKs/OgreSDK/include/OGRE/OSX -I/Developer/SDKs/OgreSDK/include/OIS -I/Developer/SDKs/OgreSDK/boost -L/Developer/SDKs/OgreSDK/lib/release -lOIS -F/System/Library/Frameworks -F/Library/Frameworks -framework Carbon -framework AppKit -framework Foundation -framework IOKit -F/Developer/SDKs/OgreSDK/lib/release -framework Cg -framework Ogre
即使链接器没有抱怨Ogre.framework,我得到这个错误基本上意味着缺少Ogre :: Root定义。 (至少我认为)
Undefined symbols for architecture x86_64:
"Ogre::Root::Root(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main-3183b9.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
我似乎无法找到导致此链接错误的原因。我有什么遗失或者我可能误解了吗?