Cross compiling static C hello world for Android using arm-linux-gnueabi-gcc
Solution 1:
Try specifying the architecture/cpu. It sounds like the compiler is creating code with a higher architecture version than the emulator can handle.
This might work:
arm-linux-gnueabi-gcc -static -march=armv5 hi.c -o hi
Solution 2:
It worked for me with CodeBench compiler on ubuntu desktop. https://sourcery.mentor.com/sgpp/lite/arm/portal/release2029
Just create a static binary with this command:
arm-none-linux-gnueabi-gcc -o hello -static hello.c
then push it to phone
adb push hello /data/local/tmp
go run it:
adb shell
$ chmod 755 /data/local/tmp/hello
$ /data/local/tmp/hello
This will print Hello World on terminal. Same can be done from phone also. Use terminal emulator or SL4A bash shell to execute.