使用Android工具链进行交叉编译

时间:2015-12-10 18:39:41

标签: android android-ndk cross-compiling mpich

我需要为android编译mpich,我使用NDK arm-linux-andoirdeabi-4.8工具链来交叉编译mpi,我做了以下

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 

但我收到以下错误:

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

当我添加-lpthread

LIBS="-lc -lgcc -lpthread"

它没有编译

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

2 个答案:

答案 0 :(得分:2)

Android的特殊之处在于它实现了pthread,但没有单独的libpthread.a。简单的解决方法是add an empty library to your toolchain usr/lib

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

在运行./configure

之前

答案 1 :(得分:0)

对于libpthread问题,您有2个选项。

  1. 从配置/生成文件中删除了要求,因为pthread包含在bionics libc中
    1. 创建一个libpthead,它是libc的符号链接
    2. cd $ SYSROOT / usr / lib

      ln -s libc.a libpthread.a