cross compiling using Android toolchains

∥☆過路亽.° 提交于 2019-12-13 02:37:25

问题


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

回答1:


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




回答2:


For the libpthread problems, you have 2 options.

  1. sed out the requirement from the configure/makefiles since pthread is included in bionics libc

Or

  1. Create a libpthead that's a symlink to libc

cd $SYSROOT/usr/lib

ln -s libc.a libpthread.a



来源:https://stackoverflow.com/questions/34209320/cross-compiling-using-android-toolchains

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!