On this page you will find information for compiling OgreODE on iPhone from the most recent version, Ogre 1.7, and the most recent version of ODE.

I assume you have an Apple developer license, and you know how to compile iPhone Xcode templates, or otherwise, you can follow this tutorial for the iPhone simulator


You need to have Ogre 1.7 running on iPhone. In order to compile and run Ogre 1.7 on iPhone check this link: Building From Source - iPhone

Download the iPhoneDependecies for iOS4 (and decompress it).
Download the OgreSource 1.7, decompress it, enter to the directory, and copy the iPhoneDependencies folder.
The folder ogre_src_v1-7-1 looks like this:

MacPro:ogre_src_v1-7-1 kjuanlu$ ls -la
total 136
drwxr-xr-x  24 kjuanlu  admin    816 26 jul 00:56 .
drwxr-xr-x   4 kjuanlu  admin    136 27 jun 01:17 ..
-rw-r--r--@  1 kjuanlu  admin  15364  3 ago 22:38 .DS_Store
-rw-r--r--@  1 kjuanlu  admin    198 24 abr 18:59 .hgtags
-rw-r--r--@  1 kjuanlu  admin   7230 24 abr 18:59 AUTHORS
-rw-r--r--@  1 kjuanlu  admin   1345 24 abr 18:59 BUGS
-rw-r--r--   1 kjuanlu  admin   9300 24 abr 18:59 BuildingOgre.txt
drwxr-xr-x@ 13 kjuanlu  admin    442 24 abr 18:59 CMake
-rw-r--r--@  1 kjuanlu  admin  14838 24 abr 18:59 CMakeLists.txt
-rw-r--r--@  1 kjuanlu  admin   1135 24 abr 18:59 COPYING
drwxr-xr-x@  7 kjuanlu  admin    238 24 abr 18:59 Components
drwxr-xr-x@ 16 kjuanlu  admin    544 24 abr 18:59 Docs
drwxr-xr-x@  7 kjuanlu  admin    238 27 jun 02:18 OgreMain
drwxr-xr-x@  6 kjuanlu  admin    204 24 abr 18:59 Other
drwxr-xr-x@ 10 kjuanlu  admin    340 24 abr 18:59 PlugIns
-rw-r--r--@  1 kjuanlu  admin   1187 24 abr 18:59 README
drwxr-xr-x@  8 kjuanlu  admin    272 24 abr 18:59 RenderSystems
drwxr-xr-x@  6 kjuanlu  admin    204 27 jun 01:52 SDK
drwxr-xr-x@ 40 kjuanlu  admin   1360 25 jul 13:28 Samples
drwxr-xr-x@  6 kjuanlu  admin    204 24 abr 18:59 Scripts
drwxr-xr-x@  9 kjuanlu  admin    306 24 abr 18:59 Tests
drwxr-xr-x@ 20 kjuanlu  admin    680 26 jul 19:08 Tools
drwxr-xr-x@  6 kjuanlu  admin    204 23 jun 15:21 iPhoneDependencies

In the ogre_src_v1-7-1 folder, type in the terminal:

mkdir build && cd build 

A Xcode project has now been generated in the build directory, so to start the Ogre build, open OGRE.xcodeproj.
(Optional for Device) if you have a code signing for the device (not simulator), right-click on the SampleBrowser Target, and in the Properties Tab, setup your Identifier (this solution does not have a *.plist file)
Next, go to Project->Edit Project Settings.
In the General Tab, setup the project Format (Xcode 3.2-compatible), and Base SDK for ALL Configurations (iPhone Device 4.0, or iPhone Simulator 4.0).
(Optional for Device) In the Build tab, setup your Code Sign.
Build the solution (for the device or/and simulator).

Ogre is now compiled for iPhone. Next go with ODE.
This is a tutorial for compile Ogre 1.7, but you make sure that you have the masterfalcon project template running on the iPhone (simulator or Device) with the correct Base SDK, Identifier profile in the *.plist file, code sign, libs, headers and frameworks from this build.

Compile ODE

Download the ode-0.11.1.tar.gz from SourceForge, decompress it.
In the ode-0.11.1 folder, type in the terminal:

export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS4.0.sdk
export CC=$DEVROOT/usr/bin/gcc
export LD=$DEVROOT/usr/bin/ld
export CPP=$DEVROOT/usr/bin/cpp
export CXX=$DEVROOT/usr/bin/g++
export AR=$DEVROOT/usr/bin/ar
export AS=$DEVROOT/usr/bin/as
export NM=$DEVROOT/usr/bin/nm
export CXXCPP=$DEVROOT/usr/bin/cpp
export RANLIB=$DEVROOT/usr/bin/ranlib
export LDFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT -L/Programming/third-parties/ODE/lib"
export CFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Programming/third-parties/ODE/include"
export CXXFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Programming/third-parties/ODE/include/"
export ac_cv_func_malloc_0_nonnull=yes
export ac_cv_func_realloc_0_nonnull=yes

./configure --host=arm-apple-darwin10 --prefix=/Programming/third-parties/ODE/ --with-x=no  --disable-demos
make && make install

This code generate the libraries and headers on the folders that you specify (change the "/Programming/third-parties/ODE...." with your owns).

Integrate OgreOde on your project

Setup the masterfalcon template project with your base SDK, the Ogre headers, libs and frameworks, app identifier for the *.plist file, and code sign

Add the ODE/lib/libode.a lib into the project (as a existing framework).
Add the path ODE/lib/ into the library Search Paths.
Add the /ODE/include path into the Header Search Paths.

Download the OgreOde SourceCode with the patch for working on Ogre 1.7:
And add the Core folder into your project (Right click->Add->Existing Files... and select the Core folder).


Work with OgreOde on iPhone and Ogre 1.7

Include the header in your source:

#define id _gs_avoid_id_collision
#include "OgreOde_Core.h"
#undef id
#undef BOOL

This code avoid the "id" usage (id is a reserved word in Objective-C).

Use setUserAny/getUserAny instead the old usage (Ogre 1.7) in your source.

Set mWorld->setCFM(1e-5); instead mWorld->setCFM(10e-5); for iPhone (following the First steps with OgreODE: First steps with OgreODE)
This avoid the box cross the ground.

Calculate the timeSinceLastFrame like this:

@interface AppDelegate : NSObject <UIApplicationDelegate>
CFTimeInterval  lastFrameStartTime;
- (void)renderOneFrame:(id)sender
#pragma unused(sender)

		CFTimeInterval thisFrameStartTime = CFAbsoluteTimeGetCurrent();
		float timeSinceLastFrame = thisFrameStartTime - lastFrameStartTime;
		//cout << "frames: " << 1/timeSinceLastFrame << endl;
		lastFrameStartTime = thisFrameStartTime;


In order to call mStepper->step(timeSinceLastFrame) following the First steps with OgreODE: First steps with OgreODE

Alias: Ogre_iPhone