Ndk installation and Application

Source: Internet
Author: User

I have read many posts in this regard on the internet, basically based on previous versions of R3, because Android ndk R4 is recently released and has some changes, so I will repeat the installation process.

Installation environment Windows 7 64bit (previously installed Android ndk in Ubuntu Desktop seems to be the R3 version, it was curious at the time, this installation is to try to debugProgram)

It is a little more complicated than installing the Windows environment downloaded from ubuntu.

1. Download the android ndk R4 Windows installation package and decompress it to the desired location, for example, D: \ android

2. InstallationCygwin, Version 1.7 or later, a simulated Linux environment, you need to select the Linux-related components you want to install during installation, refer to the previous online-related componentsArticle, Install the following package

  • Autoconf2.1
  • Automake1.10
  • Binutils
  • Gcc-core
  • Gcc4-core
  • GDB
  • PCRE
  • PCRE-devel
  • GNU awk

    If a package is missing, you can continue the installation. I have installed all the seemingly needed (C/C ++.

    After installation, run cygwin and use Linux friends.

    3. You can use Vim in cygwin or modify the environment variable in the home \ <your username> \. bash_profile file in the Windows installation directory.

    Ndk =/cygdrive/<your drive letter>/<Android ndk directory> example: ndk =/cygdrive/D/Android/android-ndk-r4-windows

    Export ndk

    The name "ndk" can be used at will, because it is often used later. We recommend that you do not use it too long.

    Restart cygwin and enter CD $ ndk to enter the corresponding directory.

     

    The following is different:

    Previously, it was input build/host-setup.sh. Compile and install the local ndk environment.

    Update. This sentence is not required after the R4 version.

    View overview. txt in the ndk doc directory.

    Previous releases required that you run the 'build/host-setup.sh'
    Script to configure your ndk. This step has been removed completely
    In Release 4

    Therefore, it is very important to carefully read the official documentation. After I start to study Android, I have gained a deeper understanding.

     

    4. Now we can compile the files in the JNI directory. What is JNI !? I will not talk about this. The most intuitive thing is that in the android project, the JNI file directory stores related programs written in C/C ++ and needs to be compiled using ndk.

    Compilation is simple. In cygwin, go to your android project directory (under the cygdrive directory) and run $ ndk/ndk-build.

    Actually, an executable script in the ndk directory is run.

    After compilation, the corresponding. So file will be generated in your project directory and placed in the libs/armeabi directory.

    Compile the sample file in Android ndk samples.

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.