在eclipse中配置ndk builds的自动编辑环境

参考资料:http://mobilepearls.com/labs/ndk-builder-in-eclipse/


手动运行ndk-build太麻烦,能不能让c像java那样自动编译呢?

当然可以,需要做以下配置:

1.新建一个项目编译器

2.给编译器命名,指定编译工具(ndk-build.cmd)的路径,指定被编译的项目的路径。(注意:window系统下的编译器是ndk-build.cmd,linux下是ndk-build.)

3.给编译器指定编译完成所需要刷新的代码的目录;(lib/libs)

4.指定需要编译的代码所在的目录;(jni)

5.编辑c代码,保存,自动编译,成功了;


具体介绍和图解如下:

Setting up Automatic NDK Builds in Eclipse

1.新建一个项目编译器

When editing native JNI code in an Android project using theAndroid NDKyou may configure Eclipse to automatically rebuild your project when editing native code, just as it does for java. The below steps shows how to perform the necessary configuration (note that this requires revision 4 or later of the NDK - previous revisions does not contain the necessaryndk-buildbinary):

Start by right clicking on your android project (namedhello-neonin the below screenshots) with JNI resources, and selectProperties. In the resulting dialog, choose theBuildersentry in the list to the left and press theNew...button:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

A new dialog will open presenting a list of builder types. Select theProgramtype and press theOKbutton:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home
2.给编译器命名,指定编译工具(ndk-build.cmd)的路径,指定被编译的项目的路径。(注意:window系统下的编译器是ndk-build.cmd,linux下是ndk-build.)
In the Main tab, fill in the following:
Name:
NDK Builder
Location:
/opt/android-ndk/ndk-build (or wherever your ndk-build binary is). You may use a variable as in ${system_property:user.home}/lib/android-ndk/ndk-build
Working Directory:
${workspace_loc:/hello-neon} (replace hello-neon with your project name. Press the Browse Workspace...button to select it graphically)

The result should look something like the below:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

注意:window系统下的编译器是ndk-build.cmd,linux下是ndk-build.



3.给编译器指定编译完成所需要刷新的代码的目录;(lib/libs)

Now continue with the refresh tab. Make sure the two checkboxesRefresh resources upon completion.andRecursively include sub-foldersare checked. Choose theSpecific resourcesradio button and press theSpecify Resources...button:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

Since the ndk-build process will generate files in the lib folder, we want Eclipse to discover changes made there without having to refresh manually. So select the lib folder in the project (create one if necessary) and press theFinishbutton:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

4.指定需要编译的代码所在的目录;(jni)

Now skip theEnvironmenttab and go to the finalBuild Optionstab. Make sure theRun the builder: During auto buildscheckbox is checked.

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

Since the NDK build only needs to happen when editing files in thejnifolder, check that folder and press theFinishbutton.

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

5.编辑c代码,保存,自动编译,成功了;

Now finally pressOKin the builder configuration dialog - the new NDK builder should now be up and running. Try editing any file in thejnifolder and check that theConsoleview produces output from the build process:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home
配置好之后,就会自动编译了,……。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值