Building FFTW3 in Android NDK

Download fftw3: http://www.fftw.org/download.html Create bash script android_build.sh:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
# Compiles fftw3 for Android

export NDK_DIR="/home/luohanjie/Android/Sdk/ndk/android-ndk-r21"
export INSTALL_DIR="`pwd`/jni_arm"
export TARGET=aarch64-linux-android
export API=27
export TOOLCHAIN="$NDK_DIR/toolchains/llvm/prebuilt/linux-x86_64"
export AR=$TOOLCHAIN/bin/$TARGET-ar
export AS=$TOOLCHAIN/bin/$TARGET-as
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/$TARGET-ld
export RANLIB=$TOOLCHAIN/bin/$TARGET-ranlib
export STRIP=$TOOLCHAIN/bin/$TARGET-strip
export CFLAGS="-march=armv8-a -D__ANDROID_API__=$API"

mkdir -p $INSTALL_DIR
./configure --host=$TARGET \
--prefix=$INSTALL_DIR \
LIBS="-L$LD_LIBRARY_PATH -L$SYS_ROOT/usr/lib -lc -lgcc -static-libstdc++" \
--enable-shared --enable-single --enable-neon --enable-threads --with-combined-threads --enable-maintainer-mode --disable-fortran


make -j4
make install

exit 0

Run the script:

1
sh ./android_build.sh

You should end up with libraries in directory of jni_arm.