Build the Android NDK environment the Windows XP environment1 Some Downloads
① 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, click Next
② Select the installation method. Choose to install online if you have an off-the-shelf offline package, you can choose to install offline
③ Select the installation directory (Cygwin final installation directory)
④ Setting the local package staging path (download file storage directory)
⑤ Setting the network connection mode: Default direct connection
⑥ Select the download site. This speed is faster http://mirrors.163.com
⑦ Select the installation item. In the default settings, simply select Devel (click Devel in the list to change the default to install), and the others are the defaults.
Note: binutils, gcc, Gcc-mingw, GDB, make and so on must be installed, see Refs-5
⑧ long wait until download is complete
Note: After downloading the package can be backed up, so that later can be directly offline installation, Fast Oh!
⑨ Add environment variables (System Properties, environment variables->path) for the system, as my C:/cygwin/bin
3 Cygwin environmental validation
① Run Cygwin once (Cygwin.bat) to create some user environment files
② Detection
Version of Cygwin: Cygcheck-c Cygwin
GCC version: GCC--version
Version of g++: g++--version
Make version: Make--version
GDB version: GdB--version
Results such as:
4 Configuring the NDK Path
① Extract the downloaded NDK to a directory
② Zai Cygwin home\< Your user name >\.bash_profile file last added: (Available notepad++ or ultraedit open)
ndk=/cygdrive/< your drive symbol >/<android NDK directory > Export NDK,
As my NDK=/CYGDRIVE/C/ANDROID/ANDROID-NDK-R7 export NDK
Note: The name "NDK" is a casual, often used not too long
② Verification
Restart Cygwin, input: cd $NDK
You can enter the NDK corresponding directory description settings OK.
5 compiling a project to generate a. so file
Way One:
Compile under the Cygwin command line, as shown in the three-step process
① into Android Project working directory: CD $NDK
② into the Samples\hello-jni directory, the full path is C:\Android\android-ndk-r7\samples\hello-jni
③ run: $NDK/ndk-build.
Note: the command $NDK and/ndk-build are connected together, there is no space in the middle, the actual use is to break into the full $ndk/ndk-build, do not just play ndk-build
Way two:
① in the. bash_profile file that is mentioned in step 4, add the Jni=/cygdrive/jni directory
As I can for Jni=/cygdrive/c/android/android-ndk-r7/samples/hello-jni
② CD $NDK
③ CD $jni
Generate two files after compiling compiled normally, for example, generate the corresponding. So file in the project Libs/armeabi directory.
6 integration of C + + development environment in Eclipse (alternative)
Official website: http://www.eclipse.org/cdt/downloads.php
method One : Find the online installation address of the CDT plugin that matches your eclipse version on the official website and install it in Eclipse's install New software
mode two : Download the CDT installation package that matches your eclipse version on the official website, then unzip and overwrite the plugins and feagures with the Eclipse folder.
7 compiler for C + + configuration ... 8 Common errors and workarounds
① problem: Android ndk:host ' awk ' tool is outdated, as shown in error, I encountered problems
FIX: Delete awk execution file
Reference: http://sunting-bcwl.iteye.com/blog/1278574
http://maidini.blog.163.com/blog/static/3776270420111195059911/
② mistake will Cygwin Terminal as Cygwin.bat, this problem bothered me for nearly one hours AH!!!
③ Other online issues http://bbs.chinavideo.org/viewthread.php?tid=10821&extra=page%3D2
Ubuntu11.10 environment (pending update ...)
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