Method 1.
1.google directly download the NDK source code decompression can be, the current version is android-ndk-r9d
Configuring $ndk_home and $PATH
Export ndk_home=/xxx/android-ndk-r9d
Export path= $NDK _home: $PATH
2. Extract Toolchain
Reference: docs/standalone-toolchain.html
A. Viewing the target instruction set arm or x86 or MIPS
B. Configure the directory for the header and root files used by the GCC compilation $SYSROOT
sysroot= $NDK _home/platforms/android-18/arch-arm
Export Sysroot
C. Invoking the NDK compiler
$NDK _home/build/tools/make-standalone-toolchain.sh--platform=android-18--install-dir=/tmp/my-android-toolchain
[--arch=x86] defaults to arm
D. Setting up $PATH and $CC (equivalent to the usual GCC)
Export Path=/tmp/my-android-toolchain/bin: $PATH
Export CC=ARM-LINUX-ANDROIDEABI-GCC # or export Cc=clang
Export cxx=arm-linux-androideabi-g++ # or export cxx=clang++
3. You can use $cc-o Hello hello.c
4. Upload Hello to Emulator
can be transferred to/data/under: adb push hello/data/
If the download is available: adb pull xx xx
can also be uploaded to SDcard, but at this time only read access to SDcard, you need to activate the emulator SDcard, specific method: The SDK directory:mksdcard-l sdcard 100m/xx/sdcard.img Then add-sdcard sdcard.img to load your sdcard while running the emulator, then upload and download using the pull and push buttons in Eclipse's Ddms
5. Open Emulator: ADB shell
6. Running Hello:/data/hello
Method 2.
Export ndk_home=/xxx/android-ndk-r9d
Export path= $NDK _home: $PATH
Open Eclipse
import/$NDK _home/samples/hello-jni
Hellojni (right click)----Properties
Builders----NEW----Program:
main//////
Name:ndk_builder
Location:/bin/bash
Working Directory:/bin
Arguments:--login-c "Cd/xx/android-ndk-r9d/samples/hello-jni && $NDK _home/ndk-build"
refresh//////
Refresh Resources Upon completion
Build options//////
Click the last three options----Specify resources----Hello Jni
Ok
Up Ndk_builder to the first place