IT++ and FFTW libraries need to be compiled specific to Application Binary Interface (ABI) for Android NDK.
These are the following ABIs:
- X86
- X86_64
- armeabi
- mips
- mips64
etc....
Further details can be found over here->
https://developer.android.com/ndk/guides/abis.html
IMPORTANT: Compile FFTW before IT++ as IT++ incorporates FFTW's archived library inside its own shared library.
FFTW compilation for NDK:
- Download the latest package from http://www.fftw.org/
- Unzip and go inside the folder:
cd ~/Downloads/fftw-3.3.5
- Set the compilation parameters specific to an ABI. The example is for 'armeabi'.
export NDK_ROOT="/Users/rajanya/Library/Android/sdk/ndk-bundle"
export PATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/:$PATH"
export SYS_ROOT="$NDK_ROOT/platforms/android-21/arch-arm/"
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"
export RANLIB="arm-linux-androideabi-ranlib"
export STRIP="arm-linux-androideabi-strip"
export DEST_DIR="$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/user"
- Generate Makefile:
./configure --host=arm-eabi --build=i386-apple-darwin10.8.0 --prefix=$DEST_DIR LIBS="-lc -lgcc" --disable-fortran
make && make install
IT++ compilation with FFTW for NDK:
- Download the latest package from http://itpp.sourceforge.net/4.3.1/installation.html
- Unzip and go inside the folder:
cd ~/Downloads/itpp-4.3.1
mkdir build && cd build/
- Download https://github.com/taka-no-me/android-cmake to obtain cmake toolchain file.
- Open cmake GUI. If cmake not present , visit https://cmake.org/download/
- In cmake, add the following entries:
- Where is the source code:
~/Downloads/itpp-4.3.1
- Where to build the binaries:
~/Downloads/itpp-4.3.1/build
- Then click '+Add Entry' button to add the following key-value pair:
ANDROID_NDK -> PATH -> ~/Library/Android/sdk/ndk-bundle
ANDROID_NATIVE_API_LEVEL -> STRING -> 17
ANDROID_TOOLCHAIN_NAME -> STRING -> arm-linux-androideabi-4.9
- Click
Configure -> Specify toolchain file for cross-compiling -> ~/Downloads/android-cmake-master/android.toolchain.cmake
- Click
Generate.
- Return back to terminal. Run
make && make install to build & install the shared library at /usr/local/lib/
NOTE: Repeat the above steps for each and every ABI
How to make IT++ functions available to the C++ code in Android?
- Copy /usr/local/lib/libitpp.so to <app_path>/app/libs/
- Enter the following lines in the CMake file:
- set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../libs)
- add_library(lib_itpp SHARED IMPORTED)
set_target_properties(lib_itpp PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/lib/${ANDROID_ABI}/libitpp.so)
target_link_libraries(native-lib
android
lib_itpp)
- #include<itpp/itbase.h> in your native-lib.cpp file.