How to build and setup for Android on Linux (2.2)

First, follow all the instructions on Setup and Build on Linux. While some steps could be skipped if you only want to build for Android, it is useful to diagnose problems with a desktop build first.

Second, while our dependencies require a Linux system to build, once they are built you can transfer the products to a Windows computer and use them with your existing Android project under Eclipse. More information on this is provided in the relevant step.

Casablanca depends on Boost, libiconv, and OpenSSL when used on Android. It is a non-trivial task to cross-compile libraries for Android, however there are scripts available online with nonrestrictive licenses to compile many popular libraries.

This document will walk through the steps to build Casablanca and its dependencies into a form suitable for use with Android applications.

For this walkthrough, we assume you are working within the Build_Android directory of the casablanca project.
git clone
pushd casablanca/Build_android

Install the Android SDK

The following instructions are written and tested against the android SDK version r23. Future and past versions may or may not work. The android SDK is available at The sdk standalone download can be found under the tag "Get the SDK for an existing IDE".

For this tutorial, we assume it is installed at ~/android-sdk-linux/.

Note: you may need to launch the SDK Manager (with ~/android-sdk-linux/tools/android sdk) and download the "Android 4.4.2 (API 19)" package category.

Install the Android NDK

The following instructions are written and tested against the android NDK version r9d. Future and past versions may or may not work. The android NDK is available at If version r9d is not available for download, hard links are provided below.

For this tutorial, we assume it is installed at ~/android-ndk-r9d/.

Building OpenSSL

To build OpenSSL, use the included script. This is based on the openssl1.0.1g-android project.
mkdir openssl
pushd openssl
tar xzf openssl-1.0.1h.tar.gz
cd openssl-1.0.1h
export ANDROID_NDK="$HOME/android-ndk-r9d/"
. ../../
./Configure android no-shared --prefix="`pwd`/../r9d-9-armeabiv7" --openssldir=openssl
make all install_sw

This completes building OpenSSL.

Original project link:

Building libiconv

To build libiconv, we use a process based on a blog post by Danilo Guilianelli.

cd libiconv
tar xzf libiconv-1.13.1.tar.gz
patch -b -p0 < libiconv.patch
cd libiconv-1.13.1
cd ../jni
cd ..
mkdir -p r9d-9-armeabiv7a/include
mkdir -p r9d-9-armeabiv7a/lib
cp libiconv-1.13.1/include/iconv.h r9d-9-armeabiv7a/include
cp libs/armeabi-v7a/ r9d-9-armeabiv7a/lib

Original blog post:

Building Boost

To build Boost, use a slight modification of the script provided by MysticTreeGames.

git clone
pushd Boost-for-Android
git checkout 8075d96cc9ef42d5c52d233b8ee42cb8421a2818
patch -p1 < ../boost-for-android.patch
./ "$HOME/android-ndk-r9d/"

This completes building Boost.

project link:

Preparing the Casablanca build

Casablanca uses CMake for cross-platform compatibility. To build on Android, we specifically use the android-cmake project by Andrey Kamaev.

git clone

This completes the preparation for building Casablanca.

project link:

Building Casablanca

Now we are ready to build Casablanca for Android.
mkdir build.armv7.debug
pushd build.armv7.debug
export ANDROID_NDK="$HOME/android-ndk-r9d/"
cmake ../../Release \
	-DCMAKE_TOOLCHAIN_FILE=../android-cmake/android.toolchain.cmake \
	-DANDROID_ABI=armeabi-v7a \
	-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8 \
make -j 3

This will produce a shared library called "" inside the 'build.armv7.debug/Binaries' directory for the armeabiv7a architecture. To build a release version, set the CMAKE_BUILD_TYPE to Release instead of Debug.

Using Casablanca

At a minimum, you will need to link against the following from your project:
  • build.armv7.debug/Binaries/
  • libiconv/r9d-9-armeabiv7a/lib/

You will also need to add the following paths as additional include directories:
  • ../Release/include
  • Boost-for-Android/build/include/boost-1_55

Use the included documentation with your NDK to add these prebuilt libraries and include paths. An outdated version of the relevant documentation is hosted at

If you wish to use this on a Windows installation of Eclipse and the Android NDK, you can copy the relevant libraries and include files over and they will work perfectly.

Final Notes

The above instructions are useful for reference, however if you encounter trouble while building or need to build Casablanca on multiple computers we have included a script which automatically performs the above steps.

To use it, issue the following commands:
~/casablanca/Build_android$ mkdir build && cd build
~/casablanca/Build_android/build$ ANDROID_NDK=~/android-ndk-r9d ../

This will automatically build a Release and Debug version of Casablanca under the build.armv7.debug and build.armv7.release folders.

Last edited Nov 21, 2014 at 11:54 PM by roschuma, version 1