Compiling Ember On Android

From WorldForgeWiki
Jump to: navigation, search

NOTE: Android support is under development. The Scratch board script is not wokring out of box, instead it gives some clues on how to get started with the Android build.

Scratch board


set -e

#NOTE: I'm still using 32 bit Linux, so android SDK is 32 bit binaries

# Android SDK
tar -xjf

#Android NDK
tar -xjf android-ndk-r9d-linux-x86.tar.bz2

export ANDROID_SDK=/home/sajty/dev/android/adt-bundle-linux-x86-20140321/sdk
export ANDROID_NDK=/home/sajty/dev/android/android-ndk-r9d
export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools:$ANDROID_NDK

#build Ogre deps
hg clone
cd ogredeps
mkdir build
cd build
#NOTE: default install prefix is inside the ndk, which is ok.
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/android.toolchain.cmake -DANDROID_ABI=armeabi ..
make install
cd ../..

#zzip has also a wrong name in ogre/CMake/Templates/ and it is not found by the linker (but cmake accepts it), so for now symlink solves it:
ln -s libzziplib.a libzzip.a

#Android is not officially supported by boost. I read riports that asio has limited features.
#There seems to be a problem with std::atomic on Android, and since Boost.Asio is using it (by default),
#combined with threads, one occasionally got deadlocked. Fortunately Boost.Asio makes it easy to switch
#from Std.Atomic to Boost.Atomic and this has been taken care of in the Boost-for-Android project in this commit.
git clone
cd Boost-for-Android
./ --toolchain=arm-linux-androideabi-4.8

#copy includes to /home/sajty/dev/android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/user/include
#copy boost libs to /home/sajty/dev/android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/user/lib

#Ogre is not supporting officially boost on android
#Ogre will not find boost without these symlinks
ln -s libboost_atomic-gcc-mt-1_53.a libboost_atomic.a
ln -s libboost_system-gcc-mt-1_53.a libboost_system.a
ln -s libboost_thread-gcc-mt-1_53.a libboost_thread.a
ln -s libboost_date_time-gcc-mt-1_53.a libboost_date_time.a
ln -s libboost_chrono-gcc-mt-1_53.a libboost_chrono.a

#add this line to ogre/CMake/Templates/
LOCAL_LDLIBS += -lboost_date_time -lboost_system -lboost_thread -lboost_chrono -lboost_atomic

#latest 1.9.x version which has "android" keyword in the commit message
#(to make sure that the build was tested on android)
hg clone -r 77f3a5a
cd ogre
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/toolchain/android.toolchain.cmake -DANDROID_ABI=armeabi -DANDROID_NATIVE_API_LEVEL=9 \
-DOGRE_DEPENDENCIES_DIR="/home/sajty/dev/android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/user" ..
#NOTE: When building Ogre for android, it seems the compiler is using 800MB+ RAM/thread. Don't try -j4 on x86 linux!
make install

#it seems apk contains only static libs. Ogre is static linked.

#git clone -b compile-fixes
#We should use for dependencies.