Thursday, September 30, 2010

Run “C” application on Android OS

It had been a hard time for me to dig this problem. I was trying to cross-compile a simple hello world “C” application for Android. Whenever I tried to execute the application, it gave a error as file not found. I was using the same toolchain that I used for compiling Android kerenel. However, after some googling I found following important information; We need to follow these commands to compile “C” application for Android.

$ ANDROID_NDK=~/android-ndk-1.6_r1
$ export PATH=$PATH:${ANDROID_NDK}/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin
$ alias agcc='arm-eabi-gcc --sysroot ${ANDROID_NDK}/build/platforms/android-4/arch-arm -fPIC -mandroid -DANDROID -DOS_ANDROID'

I hope this help you as well !!!