Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Android工具链进行交叉编译_Android_Android Ndk_Cross Compiling_Mpich - Fatal编程技术网

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

使用Android工具链进行交叉编译,android,android-ndk,cross-compiling,mpich,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-android

我需要为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的特殊之处在于它实现了pthread,但没有单独的libpthread.a。简单的解决方法是


在为libpthread问题运行
/configure

之前,您有两个选项

  • 由于pthread包含在仿生libc中,因此从configure/makefile中删除了需求
  • 创建一个libpthead,它是libc的符号链接
  • cd$SYSROOT/usr/lib


    ln-s libc.a libpthread.a

    我尝试了以下/ndk/toolschains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/bin/arm-linux-androideabi-ar q$SYS_ROOT/usr/lib/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!你不需要额外的ldflags=“-L.”
    这里。是的libpthread,它工作了,但实际上失败了:
    topology linux.c:1874:error:undefined引用“getline”
    topology linux.c:195:error:undefined引用“faccessat”我不知道要修补的文件的位置('cpu.c')你检查了吗?一般来说,如果库没有配置为仿生运行时,移植它可能需要非常高级的编程技能。这个特定的项目依赖于其他库,这使得任务更具挑战性。不使用android工具链可能会更简单。谢谢@alex,这非常有帮助,我一直在尝试使用buildroot,但也存在一些链接问题,这意味着我会将此标记为android工具链中pthread问题的正确答案。
    $AR q $SYS_ROOT/usr/lib/libpthread.a