现在的位置: 首页 > 综合 > 正文

安装android-ndk-1.5_r1遇到的问题及解决方法

2013年01月13日 ⁄ 综合 ⁄ 共 2144字 ⁄ 字号 评论关闭

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 -v
GNU Make 3.81
Copyright (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 A
PARTICULAR PURPOSE.

This program built for i686-pc-cygwin

gcc -v

$ gcc -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --ver
bose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libe
xecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-langu
ages=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-thre
ads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptio
ns --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc 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.sh
Please define ANDROID_NDK_ROOT to point to the root of your
Android NDK installation.

设定ANDROID_NDK_ROOT

修改当前目录(/home/username)下.bash_profile文件, 加入如下内容在文件尾部
ANDROID_NDK_ROOT=/cygdrive/e/android-ndk-1.5_r1
export ANDROID_NDK_ROOT

重新启动cygwin,编辑以上文件在windows下用txt亦可。

运行./host-setup.sh

提示:

$ ./host-setup.sh
Detecting host toolchain.

CC         : compiler check ok (gcc)
LD         : linker check ok (gcc)
CXX        : C++ compiler check ok (g++)
Generate   : out/host/config.mk
Toolchain : 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-jni
Android 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!

抱歉!评论已关闭.