I'm trying to build a simple HelloWorld application and run it on Genymotion. My building system is Ubuntu 14.04 64bit. I have Android SDK(r22.6.2) and NDK(r9d) installed.
First Attempt: Build using the prebuilt NDK ARM toolchain
TOOLCHAIN = $NDK/toolchains/arm-linux-androideabi-4.8
$TOOLCHAIN/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=$PLATFORM hello.c -o hello
adb push hello /sdcard/
./hello
I get an error
/system/bin/sh: ./Hello: not executable: magic 7F45
After doing some research, I quickly realize Genymotion has x86 arch instead of ARM
Second Attempt: Build using x86 Standalone ToolChain
Make x86 standlone toolchain first
cd $NDK/build/tools
./make-standalone-toolchain.sh --arch=x86 --platform=android-19 --install-dir=/tmp/android-toolchain --ndk-dir=../../. --system=linux-x86_64
Build Hello using the toolchain
cd tmp/android-toolchain/bin
./i686-linux-android-gcc -o Hello -c hello.c
Run Hello on Genymotion
adb push hello /data/local/tmp
adb shell
cd /data/local/tmp
./hello
/system/bin/sh: ./Hello: not executable: magic 7F45
Ran uname -a
on the genymotion machine.
Ran
file Hello
on the executable
So it should be a match.
Still getting the same error. Would really appreciate it if someone could shed some light.
Edit 1: Tried running the executable in /data/local/tmp instead of /sdcard/. Still gives the same error.
Edit 2: Ran uname
on genymotion system and file
on the executable to see if they match.
If plain GCC doesn't get your job done, you'll have to take the harder route.
You need a cross-toolchain; I suggest generating a Canadian cross toolchain using Crosstool~ng; you can use NDK's standalone toolchain as a starting point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With