Linux -- Ubuntu12.04 install NDK

Source: Internet
Author: User

Preface

This blog introduces how to install Android NDK in Ubuntu12.04 and how to install Android NDK in Ubuntu of other versions. Because Android NDK cannot be run independently as an Android Application, you must install the Android SDK before using Android NDK to develop programs.

Main content of this blog:

 

Preparations

First, you must obtain the Android NDK installation file, which can be obtained directly on the Android official website. Click to download. For this reason, the 32-bit Ubuntu is used to download android-ndk-r9d-linux-x86.tar.bz2. For example:

After the download is complete, a compressed package with a suffix of tar.bz2 can be decompressed under Ubuntu.

 

Install NDK

After obtaining the tar.bz2 compressed package, you need to decompress the package. Because tar is a standard compression format, you can directly use Ubuntu graphics to extract, right-click → extract here, you can extract it under the current folder, get a android-ndk-r9d folder. In addition to the image method provided by Ubuntu, you can also use tar statements in the terminal for decompression, you can also get a android-ndk-r9d folder. The downloaded installation file is in the Developer folder. The statement is as follows:

~/Developer$ tar jxvf android-ndk-r9d-linux-x86.tar.bz2

After decompression, you also need to configure the environment variables of the NDK. There are two options. profile file, the configuration is only valid for the current Login User, if you need to be valid for all users of the local machine, you can modify the/etc/profile file. Here, the gedit command is used as follows:

Modify the configuration file of the current logon User:

~$ sudo gedit ~/.profile 

Modify the system configuration file:

~$ sudo gedit /etc/profile

Both commands open a profile file and modify the system configuration file, for example:

 

Add at the end, and save and close:

export ANDROID_NDK=/home/bgxtand/Developer/android-ndk-r9dexport PATH=$ANDROID_NDK:$PATH

The NDK path here is/home/bgxtand/Developer. If you are not sure about the specific path, run the pwd command to view it. For example:

 

 

After saving the profile file, you also need to re-load the profile file in the system. Here you can use the following two commands to re-load the profile file in Ubuntu:

Use the source command:

~$ source /etc/profile

Run the. command:

~$ . /etc/profile

 

After configuring the environment variables of NDK, you can run the echo $ PATH command to view the current environment variable value to ensure that the current NDK directory has been added to the environment variable, as shown below:

 

At this point, we have completed the installation of NDK In Ubuntu. NDK contains a lot of sample code. to verify whether the installation of NDK is successful, you can enter ~ /Android-ndk-r9d/samples/hello-jni/jni directory, execute the ndk-build command, the effect is as follows:

 

After running the ndk-build command, there is output, indicating that NKD is successfully installed in Ubuntu.

 

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.