Update: 2015-02-18 – ndk version
You can now compile OGRE3D using NDK and the OGRE branch version 1.9. Ive followed the instruction in OGRE wiki for compiling for Android but got stuck several times in several areas and almost just give up. Im new to Android specially using the NDK and all of this just overwhelmed me. So this is a step by step guide Ive decided to make on how to compile OGRE for people that are like me, new to Android.
- Android SDK
As of this writing Eclipse is now bundled with the SDK.
- Android NDK (make sure to download one of the following versions: r8e, r8d, r8b, r7c, r7b, r7, r6b, r6, r5c, r5b, r5. Check my comment below for more info)
- OGRE 1.9 Source
As of this writing 1.9 is not officially released yet. This link points to the BitBucket OGRE source branch.
- OGRE Dependencies
- Extract the Android SDK.
- Extract the Android NDK on the same folder of the SDK so that it would now look like this
- Extract OGRE source on the same folder as the NDK
- Extract OGRE dependencies on the OGRE source folder. It should look like this
- Install CMake and MinGW
Setup Environment Variables
- Create a “ANDROID_SDK” in your env path and set it to the Android SDK path
- Add “%ANDROID_SDK%/tools” and “%ANDROID_SDK%/platform-tools” to your PATH variable
- Create a “ANDROID_NDK” in your env path and set it to the Android NDK path
- Add “%ANDROID_NDK%” to your PATH variable
- Add MinGW “bin” folder path to your PATH variable
Creating the MinGW Makefile Using CMake And Compilation
- Open CMake(cmake-gui)
- Make sure CMake “Grouped” and “Advanced” checkbox under build path are checked
- Add OGRE source and set the build path to where you want to build OGRE. Preferably on the same folder level as the source and name it “ogre_android”
- Click “Configure”
- In the drop down box select “MinGW Makefiles” and select “Specify toolchain file for cross-compiling” then click “Next” button
- Set the toolchain to “android.toolchain.cmake” this can be found in the OGRE source folder under “CMake/toolchain”
- It will auto configure and will most likely show some errors
- Under “ANDROID” make sure that “ANDROID_NATIVE_API_LEVEL” is set to 9
- Under “CMAKE” make sure that “CMAKE_MAKE_PROGRAM” is set to NDK “make”. This can be found in NDK folder under “prebuilt/windows/bin”
- Under “OGRE” make sure that “OGRE_DEPENDENCIES_DIR” is set to the extracted OGRE Android Dependencies folder
- Click “Configure” again it should now configure properly without errors then click “Generate”
- Now open “cmd” and “cd” to the CMake build path then enter “mingw32-make”
- As of this writing an error occured while building OgreJNI.
This is because this has dependencies that is not yet compiled since the ordering of the compilation was wrong. You can ignore this and just run the mingw32-make again.
- I had to export a signed apk of the SampleBrowser in Eclipse to be able to install it on my phone since the generated apk after building OGRE was having a “Parsing Error”.