我找到了一个解决方案:
$ ln -s $NDK_PATH/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-as $NDK_PATH/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/libexec/gcc/arm-linux-androideabi/4.4.3/as
首先,我运行带有选项的构建器以显示正在执行的命令:
$ ndk-build -B V=1
所以我发现了它如何执行编译器并将相同的命令传递给 strace
strace arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Ijni -DANDROID -Wa,--noexecstack -O0 -g -I/home/aleck/Dev/Android/ndk/platforms/android-8/arch-arm/usr/include -c jni/hello-jni.c -o ./obj/local/armeabi/objs-debug/hello-jni/hello-jni.o
这表明由于某种未知原因 arm-linux-androideabi-gcc 会按照标准搜索汇编程序,但在这种情况下,名称为 'as' 而不是 'arm-linux-androideabi-as'
stat64("/home/aleck/Dev/Android/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../libexec/gcc/arm-linux-androideabi/4.4.3/as", 0xbfedea68) = -1 ENOENT (No such file or directory)
stat64("/home/aleck/Dev/Android/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../libexec/gcc/as", 0xbfedea68) = -1 ENOENT (No such file or directory)
stat64("/home/aleck/Dev/Android/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/arm-linux-androideabi/4.4.3/as", 0xbfedea68) = -1 ENOENT (No such file or directory)
stat64("/home/aleck/Dev/Android/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/as", 0xbfedea68) = -1 ENOENT (No such file or directory)
vfork() = 6931
waitpid(6931, Assembler messages:
Fatal error: invalid -march= option: `armv5te'
所以我首先在预期的位置创建了一个名为“as”的软链接。