mac 10.10 下编译 ogre 1.10

在mac10.10上编译ogre着实费了不少事,下面给出简要说明,希望对大家有帮助。

大致分三步:

1.准备:

1.1 安装依赖库及工具

用macports安装依赖库(homebrew 安装后链接出问题),代码如下:

sudo port install libpng +universal jpeg +universal libxml2 +universal
sudo port install pkgconfig xmlto autoconf automake libtool
sudo port install freetype +universal freeimage +universal libzzip +universal boost +universal ois +universal
sudo port install cmake

然后打开“~/.bash_profile” 文件,添加系统路径

export CPPFLAGS="-I/opt/local/include"
export LDFLAGS="-L/opt/local/lib"
在终端加载新加路径

source ~/.bash_profile

1.2 下载源代码

ogre的源代码是用Mercurial管理的,这个软件需要安装(macports就可以安装),安装后

hg clone http://bitbucket.org/sinbad/ogre/ ogre
在当前目录下下载到源代码

1.3 准备目录

mkdir ogre-build

2. 编译

ogre的编译需要指定 c++11 和 libstdc++ ,否则会出各种链接不到或者其他的错误。

cd ogre-build
cmake -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -v -stdlib=libc++ -std=c++11" -DCMAKE_BUILD_TYPE="Debug" -DOGRE_BUILD_PLUGIN_CG=FALSE   ../ogre
make -j8     # 启动8线程,加快编译
make install
3. 启动SampleBrower.app

步一步完成后,ogre所有的文件都在ogre-build/sdk目录下了。这时在系统路径里添加ogre路径,还是修改 "~/.bash_profile"文件

export OGRE_HOME="/Users/xxx/ogre/ogre-build/sdk"
export OGRE_MEDIA_DIR="/Users/xxx/ogre-build/sdk/lib/OGRE/Samples"
现在一切都准备好了,开始拷贝编译好的framework 库到SampleBrower.app下,否则找不到库。

# 拷贝编译好的ogre库
cd ogre-build/sdk/lib/debug/Debug/
cp -r *.framework ../../../bin/debug/SampleBrowser.app/Contents/Frameworks/

# 拷贝ogre例子
cd ../../OGRE/Samples/
cp *.dylib ../../../bin/debug/SampleBrowser.app/Contents/Plugins/

再找到 ogre-build/bin/debug/ 下,找到SampleBrower.app。如果运气还不错的话,点击就能看到结果了。



4. 附近加内容

SampleBrower.app正常运行后,也不代表你幸运。小缟在之后使用ogre的时候就出现了神奇的bug。

说我ogre的一个单件类没有实例化对象,SampleBrower.app都能跑,我的就错了,上哪说理去。
我修改代码之后正常运行了
修改的文件是 ogre/ogre-nochange/PlugIns/PCZSceneManager/src/OgrePCZoneFactory.cpp

    PCZoneFactoryManager* PCZoneFactoryManager::getSingletonPtr(void)
    {
        if(!msSingleton) msSingleton = new PCZoneFactoryManager;    // **** 添加内容
        return msSingleton;
    }
    PCZoneFactoryManager& PCZoneFactoryManager::getSingleton(void)
    {  
        if(!msSingleton) msSingleton = new PCZoneFactoryManager;    // **** 添加内容
        assert( msSingleton );  return ( *msSingleton );  
    }

至此,我的ogre正常使用了,汗。。。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值