Skip to main content

History: CMake Quick Start Guide

Preview of version: 62

Image

For the impatient: Learn how to build Ogre with CMake in two minutes. If you encounter any problems or need some more advanced procedures, do read the rest of the sections below!

Introduction

This guide is designed to get you building OGRE from source with the default settings in the shortest possible time, showing you the barest minimum of CMake to do that, and minus any real discussion. Remember that there is a lot more to the hows and whys of this process, so it's a good idea to go back to the Getting Started With CMake page and read the whole thing when you have time.

We assume here that you've already downloaded / extracted the OGRE source code into a folder on your local machine. From here, go to the section for your platform.


Here we target the lowest possible Android API, which is API 10 Android 2.3.3. This build process has been tested using OGRE v1.9 and v1.10 using both Linux and Windows hosts.

General Android Build Instructions:

  1. Download and install the Android SDK:
    Copy to clipboard
    https://developer.android.com/sdk/
  2. Follow the instructions on the SDK site to use the tools included in the SDK to download and install your target Android API version.
  3. Download and install the Android NDK. Android NDK revision 8b is not supported due a bug in the toolchain.
    Copy to clipboard
    https://developer.android.com/tools/sdk/ndk/
  4. Initialize your Android SDK and NDK environment variables:
    1. Create environment variables ANDROID_SDK and ANDROID_NDK and set them to the full install path of the Android SDK and NDK respectively.
    2. Prepend %ANDROID_SDK%\tools, %ANDROID_SDK%\platform-tools, and %ANDROID_NDK% to the beginning of your PATH variable.
  5. Download and build the OGRE dependencies. This will require configuring `ogredeps` to target an Android build while running CMake.
    1. Download ogredeps.
      Copy to clipboard
      https://bitbucket.org/cabalistic/ogredeps
    2. Navigate your command prompt to the root of the ogredeps build directory.
    3. Run CMake to create your build files. ANDROID_ABI is usually armeabi-v7a, ANDROID_NATIVE_API_LEVEL should match whatever API level you downloaded via the SDK utilities, ANDROID_TOOLCHAIN_NAME should match the toolchain (i.e., build system) you wish to use from %ANDROID_NDK%\toolchains, and replace "Unix Makefiles" with whatever build system you wish to use. Assuming you are building from ogredeps/build:
      Copy to clipboard
      cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="../cmake/android.toolchain.cmake" -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=10 -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8 ..
    4. Build as usual using your target build system.
  6. Build OGRE for Android.
    1. Download the OGRE source code (either via the Mercurial repo or the compressed source archive).
    2. Run CMake from the OGRE build directory. Again, change parameters like you did while building ogredeps to suit your Android target. Assuming you want to build OGRE in the folder ogre/build, run CMake like so:
      Copy to clipboard
      cmake -DCMAKE_TOOLCHAIN_FILE="../CMake/toolchain/android.toolchain.cmake" -DOGRE_DEPENDENCIES_DIR="/path/to/ogredeps/build" -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=10 -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8 ..
    3. Build as usual using your target build system. Replace "darwin-x86" with the folder corresponding to your host build system. If using the Make build system, you may want to use the version of make included with the NDK.
      Copy to clipboard
      android-ndk/prebuilt/darwin-x86/bin/make)
  7. (Optional) Build and install the OGRE SampleBrowser onto your Android device.
    1. Download and install ant (http://ant.apache.org/bindownload.cgi) which will be used to build Android projects from the command line and install them on your device. On most OS, this could be done either manually or using a package manager (including Chocolatey on Windows, MacPorts or Homebrew on Mac OS X, or whatever package manager comes with your Linux distro).
    2. Navigate your command prompt to the SampleBrowserNDK subfolder in your OGRE build folder.
    3. Build the SampleBrowser as a native activity using ndk-build. Optionally use the "-j <# threads>" option — without the quotes of course — for a parallel build.
      Copy to clipboard
      ndk-build all
    4. Attach your Android device to your PC so that a call to 'adb devices' lists the device.
    5. Build a debug APK of the SampleBrowser and install on Android device:
      Copy to clipboard
      ant debug install


Notes on building for Android on Linux host:

Notes on building for Android on Mac OS X host:

Notes on building for Android on Windows host:
Standard NMake can only build one file at a time. For functionality similar to "make -j" (parallel builds), use JOM in place of the "nmake" command above. JOM can be found here: http://qt-project.org/wiki/jom

Here is a sample CMake configuration command for building OGRE for Android on Windows using NMake as the build system and armeabi as the Android ABI (assuming you are building from ogre/build):

Copy to clipboard
cmake -G"NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=..\CMake\toolchain\android.toolchain.cmake -DOGRE_DEPENDENCIES_DIR="/path/to/ogredeps/build" -DANDROID_ABI=armeabi -DANDROID_NATIVE_API_LEVEL=9 -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8 ..

History

Information Version
Sun 27 of May, 2018 22:35 GMT-0000 paroj 67
Sun 03 of Sep, 2017 16:38 GMT-0000 paroj 66
Sun 06 of Sep, 2015 22:10 GMT-0000 dark_sylinc 65
Thu 30 of Jul, 2015 23:51 GMT-0000 holocronweaver add Android JNI build todo 64
Sat 25 of Jul, 2015 04:03 GMT-0000 holocronweaver clarify highest Android API tested 63
Sat 25 of Jul, 2015 03:44 GMT-0000 holocronweaver substantial update to Android build instructions 62
Tue 16 of Sep, 2014 07:33 GMT-0000 DanielSefton 61
Thu 07 of Aug, 2014 19:19 GMT-0000 dark_sylinc Added video tutorial 60
Thu 07 of Aug, 2014 19:16 GMT-0000 dark_sylinc Updated build instructions for Windows. They were ancient and impossible to follow by mortals 59
Mon 19 of May, 2014 19:59 GMT-0000 sajty 58
Tue 27 of Aug, 2013 21:39 GMT-0000 wolfmanfx 57
Mon 17 of Jun, 2013 19:35 GMT-0000 edoardo Updated Ant version 1.9.0 => 1.9.1 56
Fri 17 of May, 2013 20:34 GMT-0000 edoardo And of course I forgot to update the output of the new ant command, now it's done 55
Fri 17 of May, 2013 20:29 GMT-0000 edoardo "apache-ant-1.8.4-bin.zip" doesn't exist anymore, plus the link had a double slash typo 54
Fri 29 of Mar, 2013 15:39 GMT-0000 Emerich 53
Fri 29 of Mar, 2013 15:38 GMT-0000 Emerich 52
Fri 22 of Feb, 2013 06:36 GMT-0000 c6burns updated dependency link to newer binaries (that include optimizer) 51
Fri 22 of Feb, 2013 04:06 GMT-0000 c6burns note that step 6 is optional 50
Thu 21 of Feb, 2013 21:53 GMT-0000 xavier 49
Thu 21 of Feb, 2013 21:53 GMT-0000 xavier 48
Thu 21 of Feb, 2013 21:51 GMT-0000 xavier 47
Thu 21 of Feb, 2013 21:43 GMT-0000 xavier 46
Thu 21 of Feb, 2013 20:34 GMT-0000 xavier 45
Wed 28 of Nov, 2012 11:30 GMT-0000 wolfmanfx 44
Sun 09 of Sep, 2012 22:16 GMT-0000 wolfmanfx 43