Android NDK Simple Introduction, tool installation, environment configuration

Source: Internet
Author: User

NDK Full Name: Native development Kit. 1. The NDK is a collection of tools. * The NDK provides a range of tools to help developers develop a dynamic library of C (or C + +) at a high speed, and to package the so and Java applications together as an APK on their own initiative. These tools are a huge help to developers. * NDK integrates cross compilers and provides the corresponding MK file isolation platform, CPU, API and other differences, developers simply need to change the Mk file ("which files need to compile", "compile feature requirements", etc.), you can create a so. * The NDK is able to package the so and Java applications on its own initiative, greatly reducing the developer's packaging work. 2. The NDK provides a stable, functionally limited API header file declaration. Google clearly declares that the API is stable and supports the currently advertised API in all version numbers. As seen from the ndk of this version number, these APIs support limited functionality, including: C standard library (LIBC), Standard math Library (LIBM), compression library (LIBZ), log Library (Liblog).
1. The NDK is a collection of tools. the NDK provides a range of tools to help developers develop a dynamic library of C (or C + +) at a high speed, and to package the so and Java applications together as an APK on their own initiative. These tools are a huge help to developers. The NDK integrates the cross compiler and provides the corresponding MK file isolation CPU, platform, ABI and other differences, developers simply need to change the Mk file ("which files need to compile", "compile feature requirements", etc.), you can create a so. The NDK is able to package the so and Java applications on its own initiative, greatly reducing the developer's packaging effort. 2. The NDK provides a stable, functionally limited API header file declaration. Google clearly declares that the API is stable and supports the currently advertised API in all version numbers. As seen from the ndk of this version number, these APIs support limited functionality, including: C standard library (LIBC), Standard math Library (LIBM), compression library (LIBZ), log Library (Liblog).
Prior to this, the Android platform's third-party applications were developed by relying on Java-based Dalvik specially crafted virtual machines. The release of the native SDK gives developers more direct access to Android system resources and uses the traditional C or C + + language to code and embed native library files directly into the program envelope file (. apks).

First, tool preparation


1.eclipse ADT (Here are just a few more)


2.NDK installation package (download http://developer.android.com/tools/sdk/ndk/index.html available on the website)but the path after the decompression , it is strongly recommended that you not include spaces . For example: C:\Program files\android-ndk-r9b\, which is not recommended. Why don't we suggest a space? Because we're going to run the command on the console. There is a path insidespaces,when operating in the consoleGeneral will have a problem.


3.cygwin (Compile tool to build. So library): http://www.cygwin.com/when installed, most of the default is to

Steps:

3.1 Double-click Setup-x86-64.exe, select Install from the Internet.

3.2 Fill in the installation address. As with the above, the path of the Red box section should not have spaces . Next.

3.3Local Package Directory, no need to change, direct next.
3.4 is up. Select the connection mode select connection type. Choose according to your network connection situation. The first direct connection is usually selected. And then next.
3.5 Select download site select Download site. You look at the selection, or add your own URL. I am the mirrors.163.com of choice. And then next.

3.6 Below is the Select Package page. is the page that selects the downloaded package.
here, we justyou need to download three packages: Make, Gcc-core, gcc-g++.

< Span style= "LETTER-SPACING:0.5PX; line-height:22.5px ">

Here are four operations.
   ① Click Viewbutton to change the display mode to full.
   ② in Search, enter the name of the package we need to download.
   ③ find the appropriate package, click Skip once, there is a block or a fork block.
   ④ Repeat steps ② and ③ until all the packages we need are selected.
    above four steps done, on the next step.

Next is to select the relevant package, tick the next. Then, download the required packages.

Then the next step is up.

After finish, click the desktop shortcut to open the command line form.

Command:
Make-v and Gcc-v. Suppose a string of information appears stating the installation OK.
two. Add NDK to the build configuration of Cygwin

This is a very easy step. Go to your Cygwin installation folder and enter home/[under your username]/folder with a. build_profile file.

Assuming that there is no such file, then: /cygwin installation folder/etc/skel inside, there are 3 files

. Bash_profile,. BASHRC and. Inputrc. These three files are Cygwin provided to all users, then the three files are copied to their own "user directory", that is, /cygwin installation folder /home/ [your username] under


Open with Notepad. At the end of the file, add the following two lines of sentence and save: ( Note the change . Bash_profile)

ndk=f:/jni/env/android-ndk-r9b

Export NDK

Here's an explanation: ndk=f:/jni/env/android-ndk-r9b This is your NDK's unpacked folder ( Note: Here the backslash is/, not \.) the backslash under Linux differs from Windows. I just because of this is not correct, engaged for a half day. another point, = Can not add space behind! )

Note: Once you're done, let's say your Cygwin form is open, turn it off and on again.
after opening, verify that the configuration is successful. Input
CD $NDK
If you go into your Ndk folder, that means OK. This step is only for high-speed access to the folder to compile!

Here, the NDK and the Cygwin are all installed OK. The following opens eclipse, installing the CDT.

This step is mainly to facilitate access to the folder to compile, not set or line.

three. Installing the CDT

CDT, which is the C + + edit plugin for eclipse. Because it is JNI, it will be written in C + +, it is good to install. If you don't want to pretend, it's OK, you can write in Notepad, or Visual Studio. Even if you use a needle to carve out the C code, you just have to be able to write the right.

The Eclipse plugin is installed in the same way that Help->install New software.

Here is the input cdt:http://download.eclipse.org/tools/cdt/releases/kepler. Check the main, optional to see their own needs.

Then the next step, what allows the agreement, what restart, all listen to him.

After restart, when you create a new project, see if you have C + + project. Assuming that there is a description, install OK.


References: http://my.oschina.net/lifj/blog/176916

If you have any questions, please leave a message, reproduced the source.


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.