Configure the android ndk environment in eclipse for Windows Mac and Linux

Source: Internet
Author: User

Welcome to reprint, reprint please indicate the source of http://blog.csdn.net/zengyangtech/article/details/7019350

Because Android requires a cross-compiling environment when there is a library at the underlying layer, C code needs to be compiled using ndk-build, while Java code needs to be compiled using Android SDK. Since I was not familiar with Eclipse IDE, C code is often written in Notepad during compilation, and then the ndk-Build Environment is built with cygwin, use ndk-build to compile the related so and then use eclipse to compile the Java program to use this so.

In fact, it is not so complicated. eclipse can fully compile so.

Click project> builders> New> program.

Then select location

In Windows

D: \ Android \ ndk \ ndk-r7-windows \ ndk-build.cmd

Executable ndk-build path in Linux and Mac

Then select

Working directory

D: \ Android \ ndk \ android-ndk-r6b \ samples \ <your JNI Project Name>

Select your corresponding JNI path. Then, when we compile and run this builder, The so library will be automatically compiled, and the SDK will compile the Java code, implement cross-compilation using eclipse

If you have any questions, read this article.

Http://mobilepearls.com/labs/ndk-builder-in-eclipse/

Mobile pearlslabssetting up automatic ndk builds in eclipsesetting up automatic ndk builds in eclipse

When editing native JNI code in an android project using the android ndk you 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, chooseBuildersEntry in the list to the left and pressNew...Button:

A new dialog will open presenting a list of builder types. SelectProgramType and pressOKButton:

InMainTab, 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 Browse Workspace...Button to select it graphically)

The result shoshould look something like the below:

Now continue with the refresh tab. Make sure the two checkboxesRefresh resources upon completion.AndRecursively include sub-foldersAre checked. ChooseSpecific resourcesRadio button and pressSpecify
Resources...
Button:

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 pressFinishButton:

Now skipEnvironmentTab and go to the finalBuild OptionsTab. Make sureRun the builder: During auto buildsCheckbox is checked.

Since the ndk build only needs to happen when editing files injniFolder, check that folder and pressFinishButton.

Now finally pressOKIn the builder configuration dialog-the new ndk builder shocould now be up and running. Try editing any file injniFolder and check thatConsoleView produces output from the build process:

Contact support@mobilepearls.com for feedback

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.