Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while compiling android jni sample: invalid -march= option: `armv5te'

When I try to compile some android ndk samples I always get this error:

$ 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

What's wrong with me or with my system?

like image 399
Aleck Avatar asked May 26 '12 22:05

Aleck


1 Answers

I've found a solution:

$ 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

First I ran the builder with options for it to display the commads being executed:

$ ndk-build -B V=1

so that I discovered how it executes the compiler and passed the same command to 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

which reveals that for some unknown reason arm-linux-androideabi-gcc makes a search of assembler program by thought the standard but in this case invalid name 'as' instead of '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'

so I made a soft link named 'as' in the first place where it is expected to be.

like image 68
Aleck Avatar answered Oct 18 '22 23:10

Aleck