我一直在研究一个GitHub项目,该项目交叉编译Python for Android https://github.com/GRRedWings/python3-android/tree/clang
谷歌很快就会在NDK中弃用gcc,所以我一直试图从使用gcc切换到clang。
几年前我偶然发现了这个项目并且一直试图用当前版本的库来维护它,但是这个让我很难过。我已经更新了上面的分支,我认为它正在使用clang进行编译,但它未能与以下错误链接
/home/python3-android/sdk/android-ndk-r16b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld: unrecognised emulation mode: elf_x86_64
Supported emulations: aarch64linux aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb aarch64linuxb aarch64linux32 aarch64linux32b armelfb_linux_eabi armelf_linux_eabi
clang: error: linker command failed with exit code 1 (use -v to see invocation)
../Makefile.shared:164: recipe for target 'link_app.' failed
在第一行结束时,它表示无法识别的仿真模式elf_x86_64 。我不明白它在哪里获得仿真模式,或者如何改变它。
我为arm或arm64得到了同样的错误。我使用2个文件来设置环境和makefile变量
环境 - https://github.com/GRRedWings/python3-android/blob/clang/env
和
build_single.sh - https://github.com/GRRedWings/python3-android/blob/clang/mk/build_single.sh
我是一个相对较新的交叉编译和需要的东西,而且此时只是不知道还有什么要看。
根据我继承的脚本,我有CPPFLAGS和LDFLAGS,以
开头-target aarch64-none-linux-android -gcc-toolchain $ {NDK_ROOT} /toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64
答案 0 :(得分:0)
您没有通过this->
,因此Clang默认为定位x86_64,但使用您提供的aarch64链接器。
NDK为您提供了一个工具:https://developer.android.com/ndk/guides/standalone_toolchain.html