Android ndk learning records

Source: Internet
Author: User

The game project began to turn to Cocos2d-x for development. What ndk and cygwin do you need. Start learning with a hard head.

1. Download ndk, the latest version of R7. Decompress to D: \ develop, address: http://dl.google.com/android/ndk/android-ndk-r7-windows.zip

2. Project nativeCodePut in<Project>/JNI /...

3. Create<Project>/JNI/Android. mkDescription of navive code.

4. Compile native code:
CD <project>
<Ndk>/ndk-build

5.ProgramUse the code to load the compiled. So file in the class:

Static {
System. loadlibrary ("hello-JNI ");
}

Examples of the methods used in the class:

Public native string stringfromjni ();

6. android-ndk-r7 \ samples \ has sample code, hello-JNI runs successfully.

 

Compiling native code in cygwin is only in step 4. Install the following cygwin packages:

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

In D: \ cygwin \ home \ Administrator \. bash_profile, add:

Ndk =/cygdrive/D/develop/android-ndk-r7

Export ndk

Go to cygwin bash, enter the project directory, and use $ ndk/ndk-build to compile native code. Common Errors see http://www.chinavideo.org/archiver? Tid-10821.html

 

Ndk test is successful, the first step of the long journey, then configure cocos-2d.

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.