1)、下载android-ndk-1.5_r1,从http://developer.android.com/sdk/ndk/1.5_r1/index.html
具体地址:http://dl.google.com/android/ndk/android-ndk-1.5_r1-windows.zip
下载的是windows版本。
2)、安装cygwin,先前已经装好,这里描述了。要make在3.8.1或更高的版本,可以用命令查看
make -v
$ make -vGNU Make 3.81Copyright (C) 2006 Free Software Foundation, Inc.This is free software; see the source for copying conditions.There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR APARTICULAR PURPOSE.
This program built for i686-pc-cygwin
gcc -v
$ gcc -vReading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specsConfigured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debugThread model: posixgcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
必须要装上。
3)、解压
android-ndk-1.5_r1到E:/盘
4)、编译
进入build目录,执行host-setup.sh
提示:
$ ./host-setup.shPlease define ANDROID_NDK_ROOT to point to the root of yourAndroid NDK installation.
设定ANDROID_NDK_ROOT
修改当前目录(/home/username)下.bash_profile文件, 加入如下内容在文件尾部ANDROID_NDK_ROOT=/cygdrive/e/android-ndk-1.5_r1export ANDROID_NDK_ROOT
重新启动cygwin,编辑以上文件在windows下用txt亦可。
运行./host-setup.sh
提示:
$ ./host-setup.shDetecting host toolchain.
CC : compiler check ok (gcc)LD : linker check ok (gcc)CXX : C++ compiler check ok (g++)Generate : out/host/config.mkToolchain : Checking for arm-eabi-4.2.1 prebuilt binaries
Host setup complete. Please read docs/OVERVIEW.TXT if you don't know what to do.
运行成功。
5)、接着编译samples里的例子
cd $ANDROID_NDK_ROOT
make APP=hello-jni
提示:
$ make APP=hello-jniAndroid NDK: The configuration file 'out/host/config.mk' doesnt' exist.Android NDK: Please run 'build/host-setup.sh' to generate it.build/core/main.mk:41: *** Android NDK: Aborting . Stop.
后来我把build/out目录下的host文件夹以及其中的config.mk一起复制到$ANDROID_NDK_ROOT下的out目录下再运行上面的命令$ make APP=hello-jni编译成功。
OK!