Android JNI 配置流程
一、 介绍
官 方 说 明 : JNI is the Java Native Interface. It denes a way for
managed code (written in the Java programming language) to interact
with native code (written in C/C++). It's vendor-neutral, has support for
loading code from dynamic shared libraries, and while cumbersome at
times is reasonably e$cient.
大体的意思就是 JAVA 语言的本地借口,也就是能够调用 C/C++写好的现成的方法。
二、 JNI 环境配置
在 eclipse 中想要调用 C/C++的方法,android 提供了一种方式,那就是把用 C/C++
语言编写的程序编译成.so 的文件,来调用。
1、 编写 C/C++
在 eclipse 中,android 提供了一种方式:CDT
2、 编译 C/C++
用 cygwin 来编译,这个比较麻烦,不建议使用,因为这是一个模拟的 Linux 环
境,需要很多的类库。
另外一种:NDK(用来编译成.so 文件),它包含了所必须的所有 cygwin 的东
西!
综上所述,用 CDT 编写,用 NDK 编译!
三、 搭建过程
1、 下载 eclipse 和安卓 SDK
2、 安装 CDT 与 NDK
四、 简单例子
(1)项目上点右键 properties->builders->new Locatioin 配置 ndk-build.cmd 的路
径,Working Directory 选择要编译的项目
评论0
最新资源