Cross Compile Seafile to ARM platform
Motivation
This project is working for delta sync from mobile to server. Currently, there’s no mobile program/solution has supporting to delta sync(Include Dropbox/ Goggle Drive). But the truth is that almost every pc version sync program can work as delta sync properly or not. So in this article, I’ll provide a workbench for cross compilation and evaluation. And finally come up with a reason of how to port better incremental synchronize solution on mobile platform.
Pre-work
Tool-Chain
Basically, I used the native android compilation tool-chains, Android NDK, as working tools. Due to my working situation, I use a Nvidia Shield Tablet as target device. As Zengwen said in his blog, newest updated NDK might has some issue which can influence compilation progress. So you can find other version of NDK once you have some problems. Based on what Zengwen’s blog mentioned, we can write following useful system environment and export in terminal.
Original System Environment Configuration
/# Android NDK sources and standalone toolchain is put here
export DEV=~/Android/
/# All the built binaries, libs and their header will be installed here
export PREFIX=/opt/android
/# Don't mix up .pc files from your host and build target
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
/# GCC for Android version to use
/# 4.9 is the only available version since NDK r11!
export GCC_VER=4.9
/# The building system we are using (Linux x86_64)
export BUILD_SYS=x86_64-linux-gnu
/# Set Android target API level
export ANDROID_API=22
/# Set Android target arch
export ANDROID_ARCH=arm
/# Set Android target name, according to Table 2 in
/# https://developer.android.com/ndk/guides/standalone_toolchain.html
export ANDROID_TARGET=armv7-none-linux-androideabi
/# The cross-compile toolchain we use
export TOOLCHAIN=arm-linux-androideabi
/# This is a symlink pointing to the real Android NDK r10e
export NDK=${DEV}/android-ndk
/# The path of standalone NDK toolchain
/# Refer to https://developer.android.com/ndk/guides/standalone_toolchain.html
export NDK_TOOLCHAIN=${DEV}/android-ndk-toolchain
/# this one is the absolute, prebuilt path
export SYSROOT=${NDK}/platforms/android-${ANDROID_API}/arch-${ANDROID_ARCH}
/# this one is the absolute, prebuilt path
export CROSS_PREFIX=${NDK}/toolchains/${TOOLCHAIN}-${GCC_VER}/prebuilt/linux-x86_64/bin/${TOOLCHAIN}
/# Non-exhaustive lists of compiler + binutils
export AR=${CROSS_PREFIX}-ar
export AS=${CROSS_PREFIX}-as
export LD=${CROSS_PREFIX}-ld
export NM=${CROSS_PREFIX}-nm
export CC=${CROSS_PREFIX}-gcc
export CXX=${CROSS_PREFIX}-g++
export CPP=${CROSS_PREFIX}-cpp
export CXXCPP=${CROSS_PREFIX}-cpp
export STRIP=${CROSS_PREFIX}-strip
export RANLIB=${CROSS_PREFIX}-ranlib
export STRINGS=${CROSS_PREFIX}-strings
/# Set build flags
/# Refer to https://developer.android.com/ndk/guides/standalone_toolchain.html
export PATH=$PATH:${PREFIX}/bin:${PREFIX}/lib
export CFLAGS="--sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${PREFIX}/include -fPIE -DANDROID -Wno-multichar"
export CXXFLAGS=${CFLAGS}
export CPPFLAGS="--sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${NDK_TOOLCHAIN}/include/c++/ -DANDROID -DNO_XMALLOC -mandroid"
export LIBS="-lc -lstdc++ -ld"
export LDFLAGS="-Wl,-rpath-link=-I${SYSROOT}/usr/lib -L${SYSROOT}/usr/lib -L${PREFIX}/lib -L${NDK_TOOLCHAIN}/lib"