That's the first time I write a tutorial or a guide here, and English isn't my native language, so i'm sorry about the quality of this tutorial ahead :)
Goal: To compile a c program, using gcc, for being used in an Android app.
The things you need:
Linux or linux emulator (such as VMWare).
Latest NDK from google: http://developer.android.com/tools/sdk/ndk/index.html#Downloads
All the next instructions should be done by using some Linux shell. I've used "Terminal".
create a shortcut for your NDK download dir, something like: "NDK=$HOME/android-ndk-r8b"
declare SYSROOT- which is a root directory gcc is using for compilation. something like: "SYSROOT=$NDK/platforms/android-8/arch-arm".
Link SYSROOT and the binaries needed for compilation, by typing something like:
"cd $NDK/build/tools"
"sh make-standalone-toolchain.sh --arch=arm --ndk-dir=$HOME/android-ndk-r8b --install-dir=$HOME/android-toolchain --platform=android-8"
Expand PATH, which will be used for invoking gcc. something like: "export PATH=$HOME/android-toolchain/bin:$PATH"
Create a shortcut for the Android gcc, by something like: export CC=arm-linux-androideabi-gcc
I've used android-8 as my minimum needed NDK version. You can set it to every NDK- supported SDK version, available in the NDK.
Now you can compile for arm on linux by simply invoking "$CC" instead of "gcc" for normal linux c compiling.