Building Ogre 3D for Android on Mac OSX

Prerequisites

Building Ogre

Extract the Android NDK and SDK and move the folders to a suitable location.

Add the following to ~/.profile or ~/.bash_profile:

export ANDROID_SDK="/path/to/androidsdk"
export ANDROID_NDK="/path/to/androidndk"
export PATH="$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools:$ANDROID_NDK"

Extract the dependencies package and move the Dependencies folder to the root directory of Ogre.

Open CMake. Point “Where is the source code” to the root directory of Ogre. Now copy and paste that path into “Where to build the binaries” and add “/build” to the end.

Add Entry -> ANDROID_NDK, PATH, /path/to/android/ndk
Add Entry -> OGRE_DEPENDENCIES_DIR, PATH, /path/to/ogre/deps
Add Entry* -> OGRE_CONFIG_ENABLE_GLES2_GLSL_OPTIMISER, BOOL, TRUE

*Optional – the RTSS renders incorrectly on some devices. Enabling the GLES2 optimiser fixes that, but does cause some instability for certain samples like compositor and cubemapping. Ideally the RTSS should not be used on Android, and custom shaders should be written instead.

According to this post we need to edit ogreroot/CMakeLists.txt and change:

else()
include(TestBigEndian)
test_big_endian(OGRE_TEST_BIG_ENDIAN)
endif()

to:

else()
#include(TestBigEndian)
#test_big_endian(OGRE_TEST_BIG_ENDIAN)
set(OGRE_TEST_BIG_ENDIAN FALSE)
endif()

Press Configure.

It should say “Build directory does not exist, should I create it?”. Choose Yes.

“Specify the generator for this project” should be “Eclipse CDT4 – Unix Makefiles” and “Specify toolchain file for cross-compiling” should be checked. Click Continue. In “Specify the Toolchain file”, point to ogreroot/CMake/toolchain/android.toolchain.cmake

Click Done and wait until configuration has finished. There may be errors, but we can ignore them.

ANDROID_NATIVE_API_LEVEL -> Change to 9

Press Configure again. The config values should turn white.

Press Generate.

In Terminal, cd to the build directory. Run “make”.

If it fails with “Error 2” or “Error 127”, just run make again and it should go away.

cd to the SampleBrowserNDK directory. Run:

ndk-build all -j4
android update project --target "android-17" --path ./
ant debug install

3 comments

  1. Hi
    Great Article and tutorial indeed.
    I am using ubuntu for my build system
    standard cmake method of ogre documentation works for me and I got the sample browser APK but I am having problem in making my own APP. I am unable to understand how I can make my own project directory and cpp code similar to sample browser and compile it to make my own app.
    Can you guide me in the same?
    Thanks

  2. Hi,
    I am follow your tutorial and get error. I build ogre3d 2.0 for Android on Mac osx. I get this error:
    make[2]: *** [OgreMain/CMakeFiles/OgreMain.dir/src/OgreAlignedAllocator.cpp.o] Error 1
    make[1]: *** [OgreMain/CMakeFiles/OgreMain.dir/all] Error 2
    make: *** [all] Error 2

    Can you help me? Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *