Installing Cygwin
Decompression Android-ndk-r5c-windows.zip
Decompression Cygwin Package.rar
Cygwin installation Steps
Run Setup.exe, select the third item to install from the local Cygwin
Set Cygwin to install there
Specify the location of the installation program
Select the installed content, just choose Devel.
Cygwin and NDK integration
You must open the. profile file with EditPlus and never open it with Notepad
Home folder is not empty
D:\ndk\cygwin\home\username\.bash_profile (username is the user name you logged into the computer ) add the following two lines
NDK=/CYGDRIVE/D/ANDROID-NDK-R5C-WINDOWS/ANDROID-NDK-R5C (D is the ndk-sdk After the decompression of the letter, followed by The path where the NDK is located )
Export NDK
Home folder is empty
If the after installation home directory is empty, there is no. bash_profile file, find the. bash_profile file under \cygwin\etc\skel\ to add the following two lines
ndk=/cygdrive/d/android-ndk-r5c-windows/android-ndk-r5c
Export NDK
Then copy to (C:\Documents andsettings\administrator), some Win7 to be copied to C:\Users directory, restart Cygwin can use the
For example: My NDK path is: D:\tarena\1408\program\ndk\android-ndk-r5c-windows\android-ndk-r5c
The
ndk=/cygdrive/d/tarena/1408/program/ndk/android-ndk-r5c-windows/android-ndk-r5c
Test the success of Cygwin integration with NDK
Double-click Run installed Cygwin with Desktop icon and executable file under installation path
$ CD $NDK
The path to the folder where the NDK is displayed indicates that the integration was successful
Writing C code
In Windows Explorer, locate D:\android-ndk-r5c-windows\android-ndk-r5c\samples\hello-jni\jni\hello-jni.c in view hello-jni.c, Modify Code
Generate. So
[Email protected] ~
$ CD $NDK
[Email protected]/cygdrive/d/android-ndk-r5c-windows/android-ndk-r5c
$ CD Samples
[Email Protected]/cygdrive/d/android-ndk-r5c-windows/android-ndk-r5c/sample
S
$ CD Hello-jni
[Email Protected]/cygdrive/d/android-ndk-r5c-windows/android-ndk-r5c/sample
S/hello-jni
$ $NDK/ndk-build
Gdbserver: [Arm-linux-androideabi-4.4.3]libs/armeabi/gdbserver
Gdbsetup:libs/armeabi/gdb.setup
Compile Thumb:hello-jni <= HELLO-JNI.C
Sharedlibrary:libhello-jni.so
install:libhello-jni.so = libs/armeabi/libhello-jni.so
Use. So in Andori
Copy the libs to the root directory of your Android project
Add the following code to the Android class
Advantages of using the NDK
Protect code
Code reuse.
C Fast running speed
Memory can be manually allocated, such as video
NDK Technology, Java Project calls C code