Build an android ndk Environment

Source: Internet
Author: User
From: http://blog.csdn.net/android_panda/article/details/7607946 1. Build an android Development EnvironmentSetting up the android development environment is not a key point. I believe many people who have read this article have successfully set up the environment. Let's give a brief description here. Download JDK download eclipse download Android SDK start eclipse and install ADT 2. Download and install Android ndkI am using the ndk version r5google out of the latest ndk for R6 for http://developer.android.com/sdk/ndk/index.html 3. Download and install cygwinSince make and GCC must be used to compile the ndk code, you must first build a Linux environment. cygwin is a UNIX simulation environment running on Windows, it is very useful for learning Unix/Linux operating environments or porting applications from UNIX to Windows. With this feature, you can use ndk to compile C and C ++ code without installing Linux. Next we will install cygwin step by step. First, you have to go to the http://www.cygwin.com to download setup.exe 1, and then double-click to run it, after running you will see the Installation Wizard interface: 2, click Next here let you choose the installation method: 1) install from Internet: Download the package directly from the Internet and install it immediately (after the installation is complete, the downloaded package will not be deleted, but will still be retained so that the package can be installed again next time ). 2) download without installing: Download the installation file to your local computer, but it is not installed yet. 3) install from local directory: without downloading the installation file, install it directly from a local directory containing the installation file. 3. Select the first item and click "Next". 4. Select the directory to be installed. Note that it is best not to put the directory with Chinese characters and spaces, which may cause installation problems, other options do not need to be changed. Next, click "Next", and click "Next". 6. You have three connection methods: 1) Direct Connection: direct connection. 2) use ie5 settings: Use the connection parameter settings of IE to connect. 3) Use http/FTP Proxy: Use http or FTP Proxy Server for connection (you need to enter the server address and port number ). You can select based on your network connection. Generally, you can select the first method, that is, direct connection. Then click "Next", 7, this is the site to download, I use a http://mirrors.kernel.org, the speed is quite fast, click Next Step 8. The installation package list will be downloaded. You can enter the name of the package you want to download in search to quickly filter out the packages you want to download. The four single-choice buttons select the style of the bottom tree. By default, they do not need to be moved. The default value of view is category. We recommend that you change it to "full" to show all packages and check them again. Save some of the packages to be hidden. The check box in the lower-left corner shows whether to hide the expired package. By default, you just need to check it. Download the package we want to install below to avoid downloading it all, the following packages used for ndk development are listed: autoconf2.1, automake1.10, binutils, GCC-core, GCC-G ++, gcc4-core, gcc4-g ++, GDB, PCRE, PCRE-devel, gawk, make a total of 12 packages 10, then start to install these packages, click skip to convert it to the digital version format. Make sure that the bin item is converted into a cross sign, and the SRC item is the source code. This is unnecessary. 11. Test whether cygwin has been installed. Run cygwin. In the displayed command line window, enter the cygcheck-C cygwin command to print the current cygwin version and running status. If the status is OK, cygwin runs normally. Then input gcc-version, G ++ -- version, make-version, and GDB-version in sequence for testing. If both print the published version information and some description information, I am very happy to tell you, your cygwin installation is complete! 4. Configure ndk Environment Variables1. First find the installation directory of cygwin and find a home \ <your username> \. bash_profile file. Mine is: e: \ cygwin \ home \ Administrator \. bash_profile, (note: I didn't have any Trojans in my home folder during installation. Solution: First open the environment variable and delete the home variable from the user variable. In E: in the \ cygwin \ home folder, create a folder named "Administrator" (user name), and then set E: \ cygwin \ etc \ skel \. bash_profile ). 2. Open the bash_profile file and add ndkroot =/cygdrive/<your drive letter>/<Android ndk directory> for example: ndkroot =/cygdrive/D/ndk/android-ndk-r8b-windows/android-ndk-r8bexport ndkrootndk this name is random, for the convenience of later use, choose a short name, then save 3, open cygwin, enter CD $ ndkroot. If the/cygdrive/D/ndk/android-ndk-r8b-windows/android-ndk-r8b information configured above is output, the environment variable is set successfully. 5. Use ndk to compile the program1. Now let's compile a simple program with the installed ndk. Let's choose the built-in ndk example hello-JNI, my location is E: \ android-ndk-r5 \ samples \ hello-JNI (depending on your location), 2. Run cygwin, enter the command CD/cygdrive/e/android-ndk-r5/samples/Hello-JNI, go to the E: \ android-ndk-r5 \ samples \ hello-JNI directory. 3. Enter $ ndkroot/ndk-build. After successful execution, it will automatically generate a libs directory and put the compiled. So file in it. ($ Ndk is used to call the environment variables we configured previously, and ndk-build is used to call the ndk Compilation Program.) 4. Go to the libs directory of hello-JNI to check whether any environment variables have been generated. so file. If yes, your ndk will run normally!

Note: If the/ndk-Build: no such file or directory error occurs when you run $ ndkroot/ndk-build, check that make.exe is available in the cygwin \ binfile. If not, click the setup file again, click View on the Select Packages page, enter make in search, find the installation package of make, and click Next to install packages.

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.