Chinaunix首页 | 论坛 | 博客
  • 博客访问: 138604
  • 博文数量: 52
  • 博客积分: 863
  • 博客等级: 准尉
  • 技术积分: 510
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-24 17:54
个人简介

没有人生,没有爱情!

文章分类

全部博文(52)

文章存档

2014年(9)

2013年(20)

2012年(17)

2011年(6)

我的朋友

分类: iOS平台

2013-02-22 17:09:48

经过一天的努力终于成功编译ogre 的ios版本,具体过程和注意事项纪录如下:

主要步骤:

1. 下载ogre for iOS source code, ogre xcode template, ogre 依赖库;

2. 编译

3. 安装ogre xcode template

4. 从模板创建ogre 工程,真机,模拟器运行测试

5. 完成


具体细节:

1. 下载ogre for iOS source code, ogre xcode template, ogre 依赖库;

    到ogre 官网下载最新源代码,包括 ogre 源代码 和 ios 预编译依赖包(ios precompiled dependencies);

    下载ogre xcode template

    这里需要注意,template直接在1.8.2上貌似不能成功安装,我的方法是在低版本系统安装好后把template目录考到当前系统上(/Library/Developer/Xcode/Templates/Ogre)

2. 编译

    首先解压源码,然后把依赖包解压到源码根目录下;

    根目录下执行以下脚本(官方的脚本貌似不能工作,所以做了一些修改):

#! /bin/bash
 
#############
# CONSTANTS #
################################################################################
 
# Absolute path to the source code directory.
SRC=`pwd`/
 
# Absolute path to the build directory.
BUILD=`pwd`/build/iOS
 
# The build configuration. Recommended values are:
#   Release        - optimized code that excludes debugging information.
#   RelWithDebInfo - optimized code that includes debugging information.
CONFIG=Release
 
################################################################################
 
# Clear the old build and recompile the new one.
rm -rf $BUILD
mkdir -p $BUILD
cd $BUILD
cmake -D OGRE_BUILD_PLATFORM_APPLE_IOS=1 -G Xcode $SRC
cd $BUILD
xcodebuild -sdk iphoneos -configuration $CONFIG ONLY_ACTIVE_ARCH=NO
mkdir -p $BUILD/lib/Release-iphoneos
mv $BUILD/lib/Release/* $BUILD/lib/Release-iphoneos
xcodebuild -sdk iphonesimulator -configuration $CONFIG ARCHS=i386 ONLY_ACTIVE_ARCH=YES
mkdir -p $BUILD/lib/Release-iphonesimulator
mv $BUILD/lib/Release/* $BUILD/lib/Release-iphonesimulator
for FILE in `ls $BUILD/lib/Release-iphoneos`
do
  lipo $BUILD/lib/Release-iphoneos/$FILE \
    -arch i386 $BUILD/lib/Release-iphonesimulator/$FILE \
    -create -output $BUILD/lib/Release/$FILE
done
rm -rf $BUILD/lib/Release-iphoneos
rm -rf $BUILD/lib/Release-iphonesimulator
 
# Copy the dependencies.
cp -R $SRC/iOSDependencies $BUILD
ln -s $BUILD/iOSDependencies/include/OIS $BUILD/include/OIS
rm -rf $BUILD/iOSDependencies/lib/Debug
 
# Add necessary files to the lib directory.
mv $BUILD/pkgconfig $BUILD/lib
 
# Remove samples, which are not useful as libraries.
rm $BUILD/lib/Release/*Sample*
 
# Add necessary files to the include directory.
mkdir -p $BUILD/include/OGRE
mkdir -p $BUILD/include/OGRE/iOS
mkdir -p $BUILD/include/OGRE/Paging
mkdir -p $BUILD/include/OGRE/Plugins
mkdir -p $BUILD/include/OGRE/Plugins/BSPSceneManager
mkdir -p $BUILD/include/OGRE/Plugins/OctreeSceneManager
mkdir -p $BUILD/include/OGRE/Plugins/OctreeZone
mkdir -p $BUILD/include/OGRE/Plugins/ParticleFX
mkdir -p $BUILD/include/OGRE/Plugins/PCZSceneManager
mkdir -p $BUILD/include/OGRE/Property
mkdir -p $BUILD/include/OGRE/RenderSystems
mkdir -p $BUILD/include/OGRE/RenderSystems/GLES
mkdir -p $BUILD/include/OGRE/RenderSystems/GLES/EAGL
mkdir -p $BUILD/include/OGRE/RenderSystems/GLES2
mkdir -p $BUILD/include/OGRE/RenderSystems/GLES2/EAGL
mkdir -p $BUILD/include/OGRE/RTShaderSystem
mkdir -p $BUILD/include/OGRE/Terrain
mkdir -p $BUILD/include/OGRE/Threading
mv $BUILD/include/OgreBuildSettings.h $BUILD/include/OGRE
cp $SRC/OgreMain/include/*.h $BUILD/include/OGRE
cp $SRC/Samples/Common/include/* $BUILD/include/OGRE
cp $SRC/OgreMain/include/iOS/* $BUILD/include/OGRE/iOS
cp $SRC/Components/Paging/include/* $BUILD/include/OGRE/Paging
cp $SRC/Plugins/BSPSceneManager/include/* $BUILD/include/OGRE/Plugins/BSPSceneManager
cp $SRC/Plugins/OctreeSceneManager/include/* $BUILD/include/OGRE/Plugins/OctreeSceneManager
cp $SRC/Plugins/OctreeZone/include/* $BUILD/include/OGRE/Plugins/OctreeZone
cp $SRC/Plugins/ParticleFX/include/* $BUILD/include/OGRE/Plugins/ParticleFX
cp $SRC/Plugins/PCZSceneManager/include/* $BUILD/include/OGRE/Plugins/PCZSceneManager
cp $SRC/Components/Property/include/* $BUILD/include/OGRE/Property
cp $SRC/RenderSystems/GLES/include/*.h $BUILD/include/OGRE/RenderSystems/GLES
cp $SRC/RenderSystems/GLES/include/EAGL/* $BUILD/include/OGRE/RenderSystems/GLES/EAGL
cp $SRC/RenderSystems/GLES2/include/*.h $BUILD/include/OGRE/RenderSystems/GLES2
cp $SRC/RenderSystems/GLES2/include/EAGL/* $BUILD/include/OGRE/RenderSystems/GLES2/EAGL
cp $SRC/Components/RTShaderSystem/include/* $BUILD/include/OGRE/RTShaderSystem
cp $SRC/Components/Terrain/include/* $BUILD/include/OGRE/Terrain
cp $SRC/OgreMain/include/Threading/* $BUILD/include/OGRE/Threading
 
# Remove everything except headers and libraries.
for FILE in `ls $BUILD`
do
  if [ $FILE != "include" ] &&
     [ $FILE != "iOSDependencies" ] &&
     [ $FILE != "lib" ]
  then
    rm -rf $FILE
  fi
done


注意最后应该有两个SUCCESS提示;


3. 安装ogre xcode template

4. 从模板创建ogre 工程,真机,模拟器运行测试

    从模板创建ogre工程会提示制定ogre sdk路径,请填写上一步的$BUILD,这里有个问题,创建好的工程会编译不过,提示找不到ogrecamera.h文件。

    此时需要修改工程中header 和 library 的搜索路径,在最前面加一个/,如果把ogre sdk 放在工程的目录下,那么也可以指定相对路径;

    还有一个地方需要注意的是,上一步修改后编译通过,链接会报错,提示boost::system::xxx错误,解决方法是在链接选项里面加上-lboost_system

    这样就ok了

5. 完成

touch4 运行结果, 效果还是很赞的~

阅读(8053) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~