Game Development Reference
In-Depth Information
Listing 2-3. Native library implementation (ch02.ccp)
#include "ch02_project_ProjectActivity.h"
JNIEXPORT jstring Java_ch02_project_ProjectActivity_getMyData
(JNIEnv* pEnv, jobject pThis)
{
return pEnv->NewStringUTF("Hello Chapter2! My first Android NDK/JNI Project");
}
Compiling the Shared Library
Before you can run your native Android app, you need to compile the native C library. For
that, the file Android.mk was created as we saw earlier in the jni folder of the project. You
can decide to build the library using the Cygwin tool or using Eclipse.
Using the Cygwin tool to build the library:
1.
Open your Cygwin console and change to the folder containing the
project files.
cd <root folder of the project>/
Run the following command: <path_where_NDK_is_placed>/
ndk-build
In the case of your ch02.Project :
2.
$cd [PATH_TO]/ch02.Project
Then call the helpful NDK build script ndk-build (see Figure 2-10 ).
3.
$ ndk-build
Figure 2-10. Native library compilation with Cygwin
 
Search WWH ::




Custom Search