Game Development Reference
In-Depth Information
Note The NDK build system is a really complex beast under the hood. You can modify pretty much
any aspect of how your code is built with the Android.mk and Application.mk files. If you want
to learn more about the build system, have a look into the doc/ folder of your NDK installation.
Now it's time to build our shared library. To do that, open your terminal, make sure your PATH
environment variable is in order, navigate to the root directory of your project, and issue the
following command:
ndk-build
If all went well, you should be greeted with the following output:
Compile++ arm : jniutils <= jniutils.cpp
In file included from jni/jniutils.h:2:0,
from jni/jniutils.cpp:2:
D:/workspaces/book/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/jni.h:592:13: note:
the mangling of 'va_list' has changed in GCC 4.4
StaticLibrary : libstdc++.a
SharedLibrary : libjniutils.so
Install : libjniutils.so => libs/armeabi/libjniutils.so
Compile++ arm : jniutils <= jniutils.cpp
In file included from jni/jniutils.h:2:0,
from jni/jniutils.cpp:2:
D:/workspaces/book/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/jni.h:592:13: note:
the mangling of 'va_list' has changed in GCC 4.4
StaticLibrary : libstdc++.a
SharedLibrary : libjniutils.so
Install : libjniutils.so => libs/armeabi-v7a/libjniutils.so
Compile++ x86 : jniutils <= jniutils.cpp
StaticLibrary : libstdc++.a
SharedLibrary : libjniutils.so
Install : libjniutils.so => libs/x86/libjniutils.so
Compile++ mips : jniutils <= jniutils.cpp
StaticLibrary : libstdc++.a
SharedLibrary : libjniutils.so
Install : libjniutils.so => libs/mips/libjniutils.so
This cryptic output tells us a few things. First, our code got compiled for each of the four CPU
architectures separately. The resulting shared libraries are all called libjniutils.so . They are
placed in the libs/ folder. Each architecture has a subdirectory (e.g., armeabi or x86 ). When
we compile our APK, those shared libraries get packaged with our application. When we call
System.loadLibrary() , as in Listing 13-1, Android knows where to find the correct shared library
for the architecture on which our application is currently running. Great, let's put this to a test!
Search WWH ::




Custom Search