当我尝试编译一些android ndk示例时,我总是会收到此错误:
$ cd ~/Dev/Android/ndk/samples/hello-jni
$ ~/Dev/Android/ndk/ndk-build
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile thumb : hello-jni <= hello-jni.c
Assembler messages:
Fatal error: invalid -march= option: `armv5te'
make: *** [obj/local/armeabi/objs-debug/hello-jni/hello-jni.o] Error 1
我或我的系统出了什么问题?
答案 0 :(得分:12)
我找到了解决方案:
$ 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'的软链接。