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
directory of the casablanca project.
git clone https://git01.codeplex.com/casablanca
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/
To build OpenSSL, use the included android_configure_armeabiv7.sh
script. This is based on the openssl1.0.1g-android project.
tar xzf openssl-1.0.1h.tar.gz
./Configure android no-shared --prefix="`pwd`/../r9d-9-armeabiv7" --openssldir=openssl
make all install_sw
This completes building OpenSSL.
Original project link:
To build libiconv, we use a process based on a blog post by Danilo Guilianelli.
tar xzf libiconv-1.13.1.tar.gz
patch -b -p0 < libiconv.patch
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/libiconv.so r9d-9-armeabiv7a/lib
Original blog post:
To build Boost, use a slight modification of the script provided by MysticTreeGames.
git clone https://github.com/MysticTreeGames/Boost-for-Android
git checkout 8075d96cc9ef42d5c52d233b8ee42cb8421a2818
patch -p1 < ../boost-for-android.patch
This completes building Boost.
project link: https://github.com/MysticTreeGames/Boost-for-Android
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 https://github.com/taka-no-me/android-cmake.git
This completes the preparation for building Casablanca.
project link: https://github.com/taka-no-me/android-cmake/
Now we are ready to build Casablanca for Android.
cmake ../../Release \
make -j 3
This will produce a shared library called "libcpprest.so" inside the 'build.armv7.debug/Binaries' directory for the armeabiv7a architecture. To build a release version, set the
instead of Debug
At a minimum, you will need to link against the following from your project:
You will also need to add the following paths as additional include directories:
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.
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 ../configure.sh
This will automatically build a Release and Debug version of Casablanca under the