Prerequisites
- Download and install CMake: http://www.cmake.org/cmake/resources/software.html
- Download the latest dependencies package AndroidDependencies_[Date].zip: http://sourceforge.net/projects/ogre/files/ogre-dependencies-android/1.9/
- Clone the Ogre v1-9 branch with the following command: hg clone https://bitbucket.org/sinbad/ogre -r v1-9
- Download Android NDK r8e 32 bit from: http://dl.google.com/android/ndk/android-ndk-r8e-darwin-x86.tar.bz2
- Download Android SDK from: http://developer.android.com/sdk/index.html
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
Excellent & Thanks a lot. It worked perfectly.
Bless you 🙂
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
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