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. mk
Description 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.