"Go" Android ndk Learn (2) Windows NDK Development environment configuration

Source: Internet
Author: User

First, configure the Android development environment.

now the Android SDK version is 4.4, almost no configuration, download and unzip, SDK and Android development dedicated eclipse has. Like.

Ii. Download and install the Android NDK

Download the latest version, unzip it.

  June 7, 2013: The current version has reached r8e.

Third, download install Cygwin

Since the NDK compiles code with make and GCC, you must first build a Linux environment, Cygwin is a UNIX simulation environment running on the Windows platform, for learning unix/linux operating environment, or porting applications from UNIX to Windows is useful. With it, you can use the NDK to compile C, C + + code without installing Linux. Let's install Cygwin step-by-step.

1, to http://www.cygwin.com download setup.exe

2. Then double-click Run, and after running you will see the Installation Wizard interface:

3, click Next, this time let you choose the installation method:

1) Install from the Internet: downloaded directly from the Internet and installed immediately (after the installation is complete, the download of the installation files is not deleted, but is still retained for the next installation).

2) Download without installing: Just download the installation file locally, but not install it temporarily.

3) Install from the local directory: Do not download the installation files, directly from a locally containing the installation files to be installed.

Here I select the first item and then click "Next".

4, select the directory to install, note, it is best not to put in Chinese and white space in the directory, it seems to cause installation problems, the simpler the better the directory. Other options do not change, then click "Next".

5, the previous step is to choose to install Cygwin directory, this is to choose the directory where you download the installation package, the default is that you run the Setup.exe directory, directly click "Next" can.

6, at this time you have a total of three connection options:

1) Direct Connection: Connect directly.

2) Use IE5 Settings: Connect using IE's connection parameter settings.

3) Use HTTP/FTP Proxy: Connect using HTTP or FTP Proxy server (you need to enter the server address, port number).

Users can choose according to their own network connection situation, under normal circumstances, the choice of the first, that is, the direct connection method. "Next".

7, this is the choice to download the site, I use the http://mirrors.kernel.org, the speed feeling is quite fast, "next".

8. Download the list of load installation packages at this time

9, search is able to enter the name of the package you want to download, you can quickly filter out the package you want to download. The four radio buttons are the style of selecting the tree below, and by default it's OK to move. View default is category, suggest change to full show all package again check, some of the province's packages are hidden away. The bottom left corner of the check box is whether to hide the expired package, the default tick, do not care it on the line, the bottom to download the package we want to install, in order to avoid all download, here are listed below the development of the NDK needed package:autoconf2.1, automake1.10, Binutils, Gcc-core, gcc-g++, Gcc4-core, gcc4-g++, GDB, Pcre, Pcre-devel, gawk, make a total of 12 packages. Don't ask why, just do it.

June 7, 2013: It is important to note that sometimes the copy and paste may not be effective, it is better to manually enter this time.

10, then start to choose to install these packages, point skip, turn it into a digital version format, to ensure that the bin item into a fork, and the SRC item is the source code, this is not necessary to choose.

11, the following test Cygwin is not already installed.

Run Cygwin, in the popup command line window input: Cygcheck-c Cygwin command, will print out the current Cygwin version and running state, if the status is OK, then Cygwin run normally.

Then enter gcc–version,g++--version,make–version,gdb–version to test, if you print out the version information and some descriptive information, very happy to tell you,

Your Cygwin installation is complete!

June 7, 2013: During the recent test, those parameters-version seem to need to be changed to-V.

Iv. Configuring the NDK environment variables

1, first find Cygwin installation directory, find a home\< your user name >\.bash_profile file, my is: E:\cygwin\home\Administrator\.bash_profile, ( Note: When I installed my home folder under the god horse do not have, the solution: first open the environment variable, the inside of the user variable to delete the home variable, in the E:\cygwin\home folder to create a folder named Administrator (is the user name), Then copy the E:\cygwin\etc\skel\.bash_profile to the folder).

2. Open the Bash_profile file, add ndk=/cygdrive/< your drive letter >/<android NDK directory > For example:

Ndk=/cygdrive/e/android-ndk-r6

Export NDK

The NDK name is random, for the convenience of later use, choose a short name, and then save

June 7, 2013: It must be noted here, the input can not have extra symbols, it is best not to copy and paste, I tried many times, direct copy paste absolutely to error. When opening that file, it's best not to use Notepad, which I opened with notepad++.

3, open Cygwin, enter the CD $NDK, if the output of the/CYGDRIVE/E/ANDROID-NDK-R6 information configured above, it indicates that the environment variable setting is successful.

June 7, 2013: Currently the latest version is/cygdrive/e/android-ndk-r8e

V. Using the NDK to compile the program

1, now we use the installed NDK to compile a simple program, we choose the NDK's own example Hello-jni, I am located in E:\android-ndk-r5\samples\hello-jni (depending on your specific installation location),

2, run Cygwin, enter the command Cd/cygdrive/e/android-ndk-r5/samples/hello-jni, enter into the E:\android-ndk-r5\samples\hello-jni directory.

3, input $ndk/ndk-build, after successful execution, it will automatically generate a libs directory, the compiled generated. so file inside. ($NDK is to invoke the environment variables we configured earlier, Ndk-build is the compiler that calls the NDK)

4, at this time to hello-jni the Libs directory to see if there are no generated. So files, if any, your NDK is functioning properly!

Vi. integration of the C/D + + development environment in eclipse

1, install the eclipse of A/C + + Environment plug-in: CDT, here choose Online Installation.

First sign in to http://www.eclipse.org/cdt/downloads.php to find the online installation address for your Eclipse version of the CDT plugin.

2. Then click the Help menu to find the Install New software menu

3, click the Add button, the address to fill in, out of the plug-in list, select All, and then choose the next step to complete the installation

4, after the installation is complete, right click on the new project in Eclispe, if a C + + project appears, then your CDT plugin installed successfully!

"Go" Android ndk Learn (2) Windows NDK Development environment configuration

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.