如何使用g++和makefile构建Ogre应用程序 我是一个编程和编译C++的初学者。我目前正在尝试使用g++编译器和makefile在OSX 10.10上构建一个非常基本的OGRE应用程序。我的makefile基于上提供的makefile。我还使用了OSX SDK的预构建版本

如何使用g++和makefile构建Ogre应用程序 我是一个编程和编译C++的初学者。我目前正在尝试使用g++编译器和makefile在OSX 10.10上构建一个非常基本的OGRE应用程序。我的makefile基于上提供的makefile。我还使用了OSX SDK的预构建版本,c++,macos,makefile,ogre,C++,Macos,Makefile,Ogre,当我第一次尝试从OGRE 3D webiste构建时,我遇到了多个与OGRE对象和函数定义相关的链接错误。我编辑了源文件,只留下了那几行代码 #include <OgreRoot.h> #include <OgreCamera.h> #include <OgreSceneManager.h> #include <OgreRenderWindow.h> #include <OgreLogManager.h> #include <Og

当我第一次尝试从OGRE 3D webiste构建时,我遇到了多个与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;
}
尽管链接器没有抱怨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

我似乎找不到导致这种链接错误的原因。有什么我遗漏了或误解了的吗?

使用nm或字符串,检查libOIS是否包含上述符号。我真的不知道它有什么帮助。OIS库基本上用于管理鼠标和键盘输入。我知道Ogre::Root头文件包含在Ogre.framework中。我假设doptimusprime的意思是Ogre而不是OIS,因为据称找不到的符号是一个Ogre核心对象。你用的是什么食人魔版本?你是自己编译的吗?你确信这是成功的,并且这个符号确实包含在你的库中了吗?我和我们的官方Ogre OS X维护人员谈过,他的建议是使用-std=c++11-stdlib=libc++,因为苹果不赞成使用g++而支持使用clang。看看这个答案:@Philip Allgaier谢谢你的回答。我使用的是MacOS X的预构建SDK版本1.9。我还使用brew安装了g++版本4.8.4,我认为与apple版本4.2.1的错误相同。当我将-std=c++11-stdlib=libc++与苹果6.0版的铿锵版本一起使用时,如果我是对的,我会得到三个错误和一系列警告,正如你所看到的,我认为这仍然与一些缺失的定义有关。使用带有-std=c++11-stdlib=libc++标志的g++时,我也会得到非常类似的警告和错误。
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