【问题标题】:cross compiling using Android toolchains使用 Android 工具链进行交叉编译
【发布时间】:2016-03-16 12:39:00
【问题描述】:

我需要为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

【问题讨论】:

    标签: android android-ndk cross-compiling mpich


    【解决方案1】:

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

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

    运行前./configure

    【讨论】:

    • 我已经尝试了以下 /ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar q $SYS_ROOT/usr/lib/libthread .a 然后 ./configure --host=arm-linux-androideabi --prefix=home/doha/workspace/Crosscompile2/jni/mpich/ LIBS="-lc -lgcc " --disable-shared --disable-fortran - -disable-cxx --enable-pic --extra-ldflags="-L."配置:错误:无法识别的选项:`--extra-ldflags=-L.'如果我删除了 ldflag 我得到了同样的旧错误 pthread required 我还想知道要修补“cpu.c”的文件的位置
    • 它应该是 libpthread.a!而且你在这里不需要--extra-ldflags="-L."
    • 是的 libpthread ,它工作但实际上失败了:topology-linux.c:1874: error: undefined reference to 'getline' topology-linux.c:195: error: undefined reference to 'faccessat' 我不知道要修补的文件('cpu.c')的位置
    • 你检查cross-compiling mpich for Android了吗?一般来说,如果一个库没有为 bionic 运行时配置,那么移植它可能需要非常高级的编程技能。这个特定的项目依赖于其他库,这使得任务更具挑战性。 alternative approach,不使用android工具链,可能更简单。
    • 感谢@alex,这非常有帮助,我一直在尝试使用 buildroot,但也存在一些链接问题,这意味着我会将其标记为 android toolchain 中 pthread 问题的正确答案。
    【解决方案2】:

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

    1. 由于 pthread 包含在仿生学 libc 中,因此从配置/makefile 中删除了要求

    或者

    1. 创建一个 libpthead,它是 libc 的符号链接

    cd $SYSROOT/usr/lib

    ln -s libc.a libpthread.a

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-21
      • 2019-01-08
      • 2013-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-19
      相关资源
      最近更新 更多