Android NDK R8 Cygwin CDT under Window development environment installation configuration and use detailed graphic explanation

Source: Internet
Author: User

Android latest NDK R8 under Window development environment installation configuration and use of detailed graphic explanation, complete actual configuration process record (original) always want to engage in the NDK development has been delayed for other things, reference to some online information today finally set up the environment, Record the process and share it with everyone. Content directory: 1. Default basic Environment 2.NDK download and configuration 3. Install CYGWIN4.5. Installing the CDT plug-in 6. Installing the Sequoyah Plug-in 7.JNI compilation environment configuration

drew a mind map to let everyone at a glance configure the process

-----------------------------------------------first, the default base environment for the completion of the Android development environment to build my environment is jdk1.6.0_07, Eclipse3.6 (Helios) , Android SDK, ADT can develop Android apps normally. To first create an Android virtual machine, be able to run an Android app to run the NDK   II, Android NDK download and configuration download Android ndk:http://developer.android.com/tools/ Sdk/ndk/index.html recently Google's Web site is very slow sometimes may not open, need a bit of patience. Select windowsandroid-ndk-r8c-windows.zip233787657 bytes (104MB) to download and unzip to your working directory, for example: E:\ANDROID\ANDROID-NDK-R8, The Samples folder below contains 12 instance development demo projects and is a good resource for learning.   Install Cygwin c/c++ 's compilation environment requires the Linux GCC, so in the Windows environment with Cygwin to simulate linux:http://cygwin.com/install.html casually click on a Setup.exe connection can be downloaded, this is just a download of the boot program, the actual content to the next download, there is a 0.97GB need for a long time. 1. Run the Setup.exe program and click Next to proceed to the next step.  2. Select the installation method. For the first time, you can use direct connection to download the installation online, if you have an off-the-shelf offline package, you can choose to install offline (install from Local Directory).  3. Select the installation directory. For example D:\Cygwin, note that this directory refers to Cygwin the virtual machine's installation directory, not the download file staging directory, nor the NDK directory.  4. Set the local package staging path. The staging directory by default is placed in the Setup.exe's sibling directory my is http%3a%2f%2fmirrors.163.com%2fcygwin%2f, can be backed down.

Note: The first installation will pop up a warning box, do not care about him, click on the confirmation can be.

5. Set the network connection mode. Choose the first one. 6. Choose the download site address, directly select the first 163 of the site can be, this I download the maximum speed can reach 185k. 7. After loading the installation item, click Devel-default, change to Devel-install, other settings do not move, next download.

8. Wait for the download to complete, about one hours or so. After the download is complete, click Next to install, and the installation will take a long time.

9. Run the installation directory (D:\Cygwin) under "Cygwin.bat", enter: "Cygcheck-c Cygwin" command, will print out the current Cygwin version and running state, if the status is OK, then Cygwin run normally. 10. Enter: "Make–v" and, "gcc–v" command if the detection is successful, there will be the make and GCC related version information printed. 11. Set the NDK path to add the NDK path in the Windows System environment variable. Using the Linux style path "/cygdrive/e/android/android-ndk-r8", If you use "E:\ANDROID\ANDROID-NDK-R8" under Windows, Cygwin will issue a warning at compile time. 12. Run the Cygwin command line, you can directly use the $NDK environment variable, do not have to manually enter the directory four each time, using the NDK compiler: 1) Compile the NDK provided by the sample program Hello-jni (E:\android\android-ndk-r8\ SAMPLES\HELLO-JNI). 1. Run Cygwin, enter "CD $NDK/samples/hello-jni/" and go to the "Hello-jni" project directory. 2. Enter "$ndk/ndk-build" compilation. Ndk-build is the compiler that calls the NDK.

3. Use the LS command to see if a so file has been generated under libs/armeabi/, and libhello-jni.so indicates that the NDK is functioning properly. $ ls libs/armeabi/gdb.setup gdbserver libhello-jni.so can also go to E:\android\android-ndk-r8\samples\hello-jni\libs\ See if there are any generated. So files in the Armeabi directory.

2) Import the NDK Hello-jni example into Eclipse 1. Create a new Android engineering Hellojni in Eclipse. When you create Android project, tick "Create Project from existing source", where you fill in E:\android\android-ndk-r8\samples\ Hello-jni

2. Run the Com.example.hellojni.HelloJni project directly from Android Aplication.  You must have. so files before you can run them. V. Integrated C/D + + development environment in Eclipse CDTCDT plug-ins can develop both C/+ +-based native code and Java-based code in one project, plus the Sequoyah plugin can compile two pieces of code at a time. : http://www.eclipse.org/cdt/downloads.php Different versions of Eclipse to download the corresponding package, otherwise it will not be installed. Help-->about Eclipse can see its own version, my Version:helios Service Release 2 is the Helios version http://www.eclipse.org/downloads/ Download.php?file=/tools/cdt/releases/helios/dist/cdt-master-7.0.2.zipcdt-master-7.0.2.zip: This is the CDT offline installation package. (Due to file comparison, it is recommended to use offline package, 7.0.2 's 54.8m,8.1.1 103MB) installation: Install New software, Eclipse, Help, click Add. Name:cdt_ version.

Location: Click Archive to navigate to the downloaded "cdt-master-7.0.2.zip" file.

If the "Duplicate location" error appears below the location, go to avaliable software, install/update, window, preferences Remove removed from the site. If there is a missing eclipse package stating that the version you downloaded and the Eclipse version do not match, re-download the matching re-install.

It is also necessary to restart eclipse before it takes effect. After the installation has completed rebooting, a new project is created in Eclispe, and if a C + + project appears, the CDT plug-in installation is successful.

Six, install the Sequoyah plug-in (you must install the CDT before installing this, you can install the latest version of the 2.0) Sequoyah plug-in for setting up Android engineering support for native development. Official website: http://www.eclipse.org/sequoyah/downloads/Open the above URL to see the specific installation instructions location:http://download.eclipse.org/ Sequoyah/updates/2.0/for Helios SR2 Sequoyah version:http://download.eclipse.org/sequoyah/updates/1.0.2/ Note: Just install 1.0.2 not come out "native development" of the configuration so can not use, I reinstall the 2.0, this should be installed directly the latest version of 2.0 on it. Do not tick the "Group Items by category" check box on the installation screen, and select the case where the list is empty (there is no categorized items). Add the path to the NDK in Window–> preferences->android, native development.

This plug-in installation also requires restarting the "HELLOJNI" project that was created before the right-click of Eclipse's restart, including the "Add Native support ..." option in the "Android Tools" option to succeed.

Seven, the JNI compilation environment configuration now modifies the "/hellojni/jni/hello-jni.c" file, the dynamic link library libhello-jni.so file is not recompiled generated. You need to add a compilation configuration and a dependent library to the JNI project. 1. Conversion Engineering: Create a new project and select Convert to a C + + project (Adds/C + + Nature) under "C + +". Go to "next". 2. Select the "Hellojni" project you just built, choose "Cygwin GCC" on the left side of "Makefile project", click Finish to create the project.

3. Right-click on the "Hellojni" Project and select "Properties". Configure "C + + Build": click "C + + build" To remove the default check box "Use default Build Command" in "Builder Settings" on the right.

Set the build command to "Bash E:\android\android-ndk-r8\ndk-build".

4. Configure the Dependent library: C + + General-Paths and Symbols: Add a new Gnu,c dependency path under includes. "Hellojni" project Needs "E:\android\android-ndk-r8\platforms\android-8\arch-arm\usr\include", then choose different dependent libraries according to different projects.

5. Change the string "Hello from Jni!" in "/hellojni/jni/hello-jni.c" to "Hello Jni from zdz!"

6. The string output after running on the emulator is "Hello JNI from zdz!" This indicates that the configuration was successful.

By now you can develop the native code and Java-based code in a single project while developing NDK applications and developing common Android apps without feeling any difference.

You are welcome to comment on the discussion, if there is not clear in the comments can be put forward, will be updated to supplement clearly, has supplemented the part of the Cygwin installation process and precautions.

Have time to organize an article to transplant ffmpeg with the NDK.

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.