History: Building From Source - iPhone
Preview of version: 7
- «
- »
Of course you will need to have downloaded and installed CMake.
After that, head over to http://sourceforge.net/projects/ogre/files/ and download the latest iPhone dependencies package. Once it has finished downloading, double-click on the disc image to mount it. Copy the iPhoneDependencies folder to the root of the Ogre source tree. It should reside alongside folders such as OgreMain, Samples, Tests, PlugIns, etc.
Your Ogre directory should look similar to this:
CMake Components iPhoneDependencies Docs OgreMain Other PlugIns RenderSystems Samples SDK Tests Tools
The best way to configure for iPhone is using Terminal. Using CMake-Gui doesn't quite configure correctly at the time of this writing.
First change to the directory of the Ogre sources. Now create a build directory and change to it:
mkdir build && cd build
You need to run cmake from the build directory and provide it with the location of the build directory. If you followed the above guideline, then you can simply type:
cmake -D OGRE_BUILD_PLATFORM_IPHONE=1 -G Xcode ..
CMake will now parse the scripts in the Ogre source tree. Watch the output, especially if all necessary dependencies have been found. If not, you might need to install the missing ones or provide their locations manually
The linker paths are not correctly generated so now you must run the following script to take care of this. Type:
../SDK/iPhone/fix_linker_paths.sh
Then press return or enter.
A Xcode project has now been generated in the build directory, so to start the Ogre build, open OGRE.xcodeproj and build as usual.
To run samples on your device you will need to have a valid iPhone Developer certificate installed. For each sample, double click on target in the Groups & Files list. Ensure that a valid identity is selected in the Code Signing Identity drop menu.
Also, because we can't tell CMake what Xcode project format you want, you will have to change it yourself. Open the Project Menu, choose Edit Project Settings. Click on the General tab in the settings window. Change Project Format to Xcode 3.1-compatible. If you are using CMake 2.8 it is not necessary to change the Project Format.
And another thing. You will need to manually set the Bundle Identifier property of the Info.plist file to match the App ID of the chosen code signing identity. This can be done from the Target Properties panel. It must match the bundle identifier of a valid developer certificate if you are building for devices.
See the following PDF for information under Generating an App ID:
http://developer.apple.com/iphone/download.action?path=/iphone/iphone_developer_program_user_guide/iphone_developer_program_user_guidestandard_program_v2.5final.pdf
If you want to use the Xcode template installer package after building the source, use the script below to create and modify your build directory so it matches the pre-built SDK.
NOTE: If you use the script exactly as it is on here your templates will not work! The "xcodebuild" lines need to be adjusted to build for the iPhone Simulator and for other relevant parameters. What you can do is run the script up to the build lines, load Xcode yourself and build a debug and release configuration for the simulator, then run the remaining script (excluding the build lines, of course) to get what you need.
#!/bin/bash #Arguments are as follows (no argument checking exists) #1 - Path to the SDK root (relative or absolute) #2 - Path to build directory (relative or absolute) #3 - Path to iPhoneDependencies directory (relative or absolute) #Clear the old build and recompile the new one rm -rf $2 mkdir $2 cd $2 cmake -D OGRE_BUILD_PLATFORM_IPHONE=1 -G Xcode $1 $1/SDK/iPhone/fix_linker_paths.sh cd $2 xcodebuild -configuration Debug xcodebuild -configuration Release #Copy the iPhoneDependencies directory cp -R $3 $2 #Standardize the lib/* directories mkdir $2/lib/pkgconfig #Add necessary files to the Debug directory cp $3/lib/Debug/* $2/lib/Debug #Add necessary files to the Release directory cp $3/lib/Release/* $2/lib/Release cp $2/lib/Release-iphoneos/libOgreMainStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libOgrePagingStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libOgrePropertyStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libOgreRTShaderSystemStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libOgreTerrainStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libPlugin_BSPSceneManagerStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libPlugin_OctreeSceneManagerStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libPlugin_OctreeZoneStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libPlugin_ParticleFXStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libPlugin_PCZSceneManagerStatic.a $2/lib/Release cp $2/lib/Release-iphoneos/libRenderSystem_GLESStatic.a $2/lib/Release #Add necessary files to the pkgconfig directory cp $2/pkgconfig/* $2/lib/pkgconfig #Handle the include directory mkdir $2/include/OGRE mkdir $2/include/OGRE/iPhone mkdir $2/include/OGRE/Paging mkdir $2/include/OGRE/Plugins mkdir $2/include/OGRE/Plugins/BSPSceneManager mkdir $2/include/OGRE/Plugins/OctreeSceneManager mkdir $2/include/OGRE/Plugins/OctreeZone mkdir $2/include/OGRE/Plugins/ParticleFX mkdir $2/include/OGRE/Plugins/PCZSceneManager mkdir $2/include/OGRE/Property mkdir $2/include/OGRE/RenderSystems mkdir $2/include/OGRE/RenderSystems/GLES mkdir $2/include/OGRE/RenderSystems/GLES/APPLE mkdir $2/include/OGRE/RTShaderSystem mkdir $2/include/OGRE/Terrain mkdir $2/include/OGRE/Threading cp $1/OgreMain/include/*.h $2/include/OGRE cp $2/Samples/include/ExampleApplication.h $2/include/OGRE cp $2/Samples/include/ExampleFrameListener.h $2/include/OGRE cp $2/Samples/include/ExampleLoadingBar.h $2/include/OGRE cp $2/Samples/include/FileSystemLayer.h $2/include/OGRE cp $2/Samples/include/Sample.h $2/include/OGRE cp $2/Samples/include/SampleContext.h $2/include/OGRE cp $2/Samples/include/SamplePlugin.h $2/include/OGRE cp $2/Samples/include/SdkCameraMan.h $2/include/OGRE cp $2/Samples/include/SdkSample.h $2/include/OGRE cp $2/Samples/include/SdkTrays.h $2/include/OGRE cp $1/OgreMain/include/iPhone/* $2/include/OGRE/iPhone cp $1/Components/Paging/include/* $2/include/OGRE/Paging cp $1/Plugins/BSPSceneManager/include/* $2/include/OGRE/Plugins/BSPSceneManager cp $1/Plugins/OctreeSceneManager/include/* $2/include/OGRE/Plugins/OctreeSceneManager cp $1/Plugins/OctreeZone/include/* $2/include/OGRE/Plugins/OctreeZone cp $1/Plugins/ParticleFX/include/* $2/include/OGRE/Plugins/ParticleFX cp $1/Plugins/PCZSceneManager/include/* $2/include/OGRE/Plugins/PCZSceneManager cp $1/Components/Property/include/* $2/include/OGRE/Property cp $1/RenderSystems/GLES/include/*.h $2/include/OGRE/RenderSystems/GLES cp $1/RenderSystems/GLES/include/EAGL/* $2/include/OGRE/RenderSystems/GLES/APPLE cp $1/Components/RTShaderSystem/include/* $2/include/OGRE/RTShaderSystem cp $1/Components/Terrain/include/* $2/include/OGRE/Terrain cp $1/OgreMain/include/Threading/* $2/include/OGRE/Threading #Handle the Media directory cp -R $1/Samples/Media $2/media #Handle the Samples directory cp -R $1/Samples $2/Samples #Remove extra copy of the Media directory rm -rf $2/Samples/Media
Alias: Building From Source (for iPhone)