ArticleDirectory
- 1. Download
- 2 cygwin Installation
- 3 cygwin environment Verification
- 4. Configure the ndk path
- 5. compile the project to generate the. So file
- 6. Integrate the C/C ++ development environment in eclipse (optional)
- 7. Configure the C/C ++ Compiler
- ...
- 8 Common Errors and Solutions
[Android tutorial] Build an android ndk Environment
Skyseraph Feb 16th 2012 sztcl
Email: zgzhaobo@gmail.com QQ: 452728574
Ndk: Native Development Kit
[Android learning topic] Build an android Development Environment
Windows XP 1. Download
①Ndk R7: http://developer.android.com/sdk/ndk/index.html
②Cygwin: http://www.cygwin.com/(1.7.11-1)
③Notepad ++: http://notepad-plus-plus.org/download/v5.9.8.html
2 cygwin Installation
①Run the downloaded setup.exe and click Next.
②Select the installation method. Select online installation. If there is a ready-to-use offline package, you can select offline installation.
③Select the installation directory (the final installation directory of cygwin)
④Set the path for saving local packages (directory for storing downloaded files)
⑤Set network connection mode: Default direct connection
⑥Select a download site. This speed is faster http://mirrors.163.com
7.Select an installation item. Under the default settings, you only need to select devel (Click devel in the list and change the default value to install). The others are in the default status.
Note: binutils, GCC, GCC-mingw, GDB, make and other mandatory, see the Refs-5
BytesLong wait until the download is complete
Note: After downloading the package, you can back up the package so that it can be directly installed offline. This is fast!
BytesAdd environment variables (System Properties> environment variables> path) to the system. For example, if my environment is C:/cygwin/bin
3 cygwin environment Verification
①Run cygwin once (cygwin. BAT) to create some user environment files.
②Detection
Cygwin version: cygcheck-C cygwin
GCC version: GCC -- version
Version of G ++: G ++ -- version
Make version: Make -- version
GDB version: GDB -- version
The result is as follows:
4. Configure the ndk path
①Decompress the downloaded ndk to a directory.
②Last added in the home \ <your username> \. bash_profile file of Zai cygwin: (open with notepad ++ or ultraedit)
Ndk =/cygdrive/<your drive letter>/<Android ndk directory> export ndk,
Such as my ndk =/cygdrive/C/Android/android-ndk-r7 export ndk
Note: The name "ndk" can be used as long as it is often used in the future.
②Verify
Restart cygwin and enter CD $ ndk.
You can enter the corresponding directory description of ndk and set OK.
5. compile the project to generate the. So file
Method 1:
Compile in the cygwin command line. The compilation process is shown in step 3.
①Go to the android project working directory: CD $ ndk
②Enter the samples \ hello-JNI directory in sequence, and the complete path is c: \ Android \ android-ndk-r7 \ samples \ hello-JNI
③Run: $ ndk/ndk-build.
Note: This command $ ndk and/ndk-build are connected together with no spaces in the middle. In actual use, they are fully written into $ ndk/ndk-build. Do not just use ndk-build.
Method 2:
①Add the JNI =/cygdrive/JNI directory to The. bash_profile file mentioned in step 4.
If my can be JNI =/cygdrive/C/Android/android-ndk-r7/samples/Hello-JNI
②CD $ ndk
③CD $ JNI
After compilation, two files are generated. For example, the corresponding. So file is generated under the libs/armeabi directory of the project.
6. Integrate the C/C ++ development environment in eclipse (optional)
Official Website:Http://www.eclipse.org/cdt/downloads.php
Method 1: Find the online installation address of the CDT plug-in that matches your eclipse version on the official website, and install it in install new software of Eclipse.
Method 2: Download the CDT installation package that matches your eclipse version on the official website. decompress the package and copy plugins and feagures to the eclipse folder.
7. Configure the C/C ++ compiler... 8 Common Errors and Solutions
①Problem: Android ndk: Host 'awk' tool is outdated, as shown in the error.
Solution: Delete the awk execution File
Reference: http://sunting-bcwl.iteye.com/blog/1278574
Http://maidini.blog.163.com/blog/static/3776270420111195059911/
②Cygwin terminal is treated as cygwin. bat by mistake. This problem has plagued me for nearly an hour !!!
③Other online problems http://bbs.chinavideo.org/viewthread.php? Tid = 10821 & extra = Page % 3d2
Ubuntu11.10 Environment (to be updated ...)
Refs
1 http://blog.csdn.net/javatiger427/article/details/6115693
2 http://maidini.blog.163.com/blog/static/3776270420111194440211/
3 http://www.cnblogs.com/luxiaofeng54/archive/2011/08/13/2136982.html
4 http://www.metsky.com/archives/525.html
5 http://www.cnblogs.com/playing/archive/2011/07/14/2106727.html