Introduction to Android NDK, tool installation, and environment Configuration

Source: Internet
Author: User

NDK stands for Native Development Kit. 1. NDK is a collection of tools. * NDK provides a series of tools to help developers quickly develop C (or C ++) dynamic libraries and automatically package so and java applications into apk. These tools are of great help to developers. * NDK integrates with the cross compiler and provides the corresponding mk file isolation platform, CPU, API, and other differences, developers can create so simply by modifying the mk file (indicating "which files need to be compiled" and "Compilation feature requirements. * NDK can automatically package so and Java applications, greatly reducing developers' packaging work. 2. NDK provides a stable and functional API header file statement. Google explicitly states that this API is stable and supports the currently released API in all subsequent versions. From the NDK version, we can see that these Apis support very limited functions, including: C standard library (libc), standard Math Library (libm), and compression library (libz), Log Library (liblog ).
1. NDK is a collection of tools.NDK provides a series of tools to help developers quickly develop C (or C ++) dynamic libraries, and can automatically package so and java applications into apk together. These tools are of great help to developers. NDK integrates with the cross compiler and provides mk files to isolate differences such as CPU, platform, and ABI, developers can create so simply by modifying the mk file (indicating "which files need to be compiled" and "Compilation feature requirements. NDK can automatically package so and Java applications, greatly reducing developers' packaging work.2. NDK provides a stable and functional API header file statement.Google explicitly states that this API is stable and supports the currently released API in all subsequent versions. From the NDK version, we can see that these Apis support very limited functions, including: C standard library (libc), standard Math Library (libm), and compression library (libz), Log Library (liblog ).
Previously, third-party applications on the Android platform were developed by Java-based Dalvik virtual machines. S.

I. Prepare the tool


1. eclipse adt (I will introduce it more here)


2. NDK installation package (official website provides download http://developer.android.com/tools/sdk/ndk/index.html) but after decompression path, it is strongly recommended that not contain spaces. For example: C: \ Program Files \ android-ndk-r9b \, This is not recommended. Why is space not recommended? Because we need to execute commands on the console. There are spaces in the path, which may be a problem during console operations.


3. cygwin (the compilation tool is used to generate the. so Library): http://www.cygwin.com/when the installation is complete.

Steps:

3.1double-click setup-x86-64.exe and select Install from Internet.

3.2 enter the installation address. Like above, it is best not to have spaces in the path of the red box. Next step.

3.3 Local Package Directory. You do not need to modify the Directory.
3.4 The Select connection type of the connection method is selected. Select according to your network connection. Generally, the first Direct connection is selected. Next step.
3.5 Select download site. You can select or add your own url. I chose mirrors.163.com. Next step.

The Select Package page is displayed below 3.6. Is the page for selecting the downloaded package.
Here, we only need to download three packages: make, gcc-core, and gcc-g ++.

There are four operations.
① Click the view button to change the display mode to Full.
② Enter the name of the package to be downloaded in Search.
③ Find the corresponding package and click Skip once. A box or a cross box is displayed.
④ Repeat steps ② and ③ until all the packages we need are selected.
After completing the above four steps, proceed to the next step.

Next, select the related package, check the package, and click Next. Then download the required package.

Then you can continue the next step.

After finishing, click the desktop shortcut to open the command line window.

Command:
Make-v and gcc-v. If a string of information appears, install OK.
2. Add the NDK to Cygwin's build configuration.

This step is simple. Go to your Cygwin installation directory and go to the home/[your username]/directory, which contains a. build_profile file.

If this file is not available, find the/cygwin installation directory/etc/skel, which contains three files.

. Bash_profile,. bashrc and. inputrc. These three files are provided by cygwin to all users. Next, copy all the three files to your "user directory, under the/cygwin installation directory/home/[your user name]


Open it in notepad. At the end of the file, add the following two sentences and save them: (Note: Modify. bash_profile)

NDK = f:/JNI/env/android-ndk-r9b

Export NDK

Here is an explanation: NDK = f:/JNI/env/android-ndk-r9b this is the directory of your NDK decompression (Note: here the backslash is/, rather \. The backslash in linux is different from that in windows. This is why I am wrong .. Another point: = spaces are not allowed in the backend !)

Note: after adding the window, if your Cygwin window is open, close it and open it again.
Check whether the configuration is successful. Input
Cd $ NDK
If you enter your ndk directory, it means OK. This step is just to quickly enter the directory for compilation!

At this point, both NDK and Cygwin have installed OK. Open Eclipse and install CDT.

This step is mainly used to facilitate the compilation of directories.

3. Install CDT

CDT is the C/C ++ editing plug-in of Eclipse. Because it is JNI, C/C ++ will be compiled, and the installation is quite good. If you do not want to install it, it is OK. You can write it in notepad or Visual Studio. Even if you use a needle to extract C code, you only need to be able to write the correct code.

The methods for installing plug-ins in Eclipse are the same. help-> Install New Software.

Enter CDT: http://download.eclipse.org/tools/cdt/releases/kepler. Select Main, Optional depends on your needs.

Next, let's keep following the next step and listen to the agreement and restart.

After restart, when creating a Project, check whether there is a C/C ++ Project. If yes, install OK.


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

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


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.