Doha Doha - 20 days ago 5
Android Question

cross compiling using Android toolchains

I need to compile mpich for android , I used NDK arm-linux-andoirdeabi-4.8 toolchain to cross compile mpi , I did the following

export PATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/:$PATH"
export SYS_ROOT="$NDK_ROOT/platforms/android-8/arch-arm/"
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"

./configure --host=arm-linux-androideabi --prefix=/Crosscompile2/jni/mpich/ LIBS="-lc -lgcc " --disable-shared --disable-fortran --disable-cxx

but I got the following error:

checking for pthread_key_create in -lpthread... no
checking checkpointing library... configure: error: pthreads is required for checkpointing, but was not found
configure: error: src/pm/hydra configure failed

when I added -lpthread

LIBS="-lc -lgcc -lpthread"

it didn't compile

checking whether the C compiler works... no
configure: error: C compiler cannot create executables


Android is special in that it implements pthreads, but does not have a separate libpthread.a. The easy workaround is to add an empty library to your toolchain usr/lib

$AR q $SYS_ROOT/usr/lib/libpthread.a

before running ./configure