Build an Android NDK Environment

Source: Internet
Author: User

It is easy to build the NDK environment in linux. Now we will first build the NDK in windows. 1. Download and install Android NDK.

Developer.android.com/sdk/ndk/index.html

Download the latest NDK from google

2. Download and install cygwin Make and gcc must be used to compile NDK code. cygwin is a unix simulation environment running on windows. setup.exe must be downloaded from www.cygwin.com.

1. Double-click "run". After running, you will see the Installation Wizard interface:

2. Click Next and select the installation method: 1) Install from Internet: Install online. 2) Download Without Installing: Download the installation file to your local computer, but it is not installed yet. 3) Install from Local Directory: Install the package offline without downloading the installation file. Select option 1 3. Select the directory to be installed. Note, it is best not to put it in the directory with Chinese characters and spaces 4. Select the directory where the downloaded installation package is located 5. Select network Connection method 1) Direct Connection: Direct Connection. 2) Use IE5 Settings: Use the connection parameter Settings of IE to connect. 3) Use HTTP/FTP Proxy: Enter the server address and port number to connect to the server using the HTTP or FTP Proxy Server ). Can be selected according to the actual situation of their network connection, under normal circumstances, all choose the first 6, select the site to download, I use http://mirrors.kernel.org

7. Download and load the installation package list, change Devel Default to install

8. test whether the installation is successful: Enter make-v and gcc-v with the corresponding version information.

 

3. Configure NDK Environment Variables

1. Find the cygwin installation directory, find a home \ <your username> \. bash_profile file, and add NDK =/cygdrive/<your drive letter>/<android ndk directory>

Example: NDK =/cygdrive/G/android_ndk/android-ndk-r7c

Export NDK)

2. Save and restart cygwin. Input cd $ NDK. If the NDK directory is displayed, OK.

Note: Opening. bash_profile cannot be opened in Notepad. You can use Notepad ++ or other tools to open and compile the file. Otherwise, the NDK path will be found.

 

Configure NDK in Ubuntu

1. Decompress NDK tar-xvf android-ndk-r7c-linux-x86.tar

2. Configure the NDK Environment

Vi ~ /. Bashrc

Add the following content:

NDK = home/iris/android-ndk-r7c (you extract the NDK address)

Export NDK

3. read and execute in the current bash environment ~ /. Bashrc

$ Source ~ /. Bashrc

Or (the source command is also called the "dot command", that is, a dot symbol (.).)

$ .~ /. Bashrc

4. Check whether the modification takes effect: If your write address is displayed, configure OK)

$ Echo $ NDK

Home/iris/android-ndk-r7c

5. Compile hello-jni

Cd/home/iris/android-ndk-r7c/samples/hello-jni

Enter the example directory

$ NDK/ndk-bNDK/ndk-build

If there are obj and libs packages in the hello-jni directory, OK

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.