Compiling the native static libraries for Android
Android NDK includes a number of GCC and Clang toolchains for each kind of the supported processors.
Getting ready
When building a static library from the source code, we follow the steps similar to the Windows version.
How to do it...
Create a folder named
jni
and create theApplication.mk
file with the appropriate compiler switches, and set the name of the library accordingly. For example, one for the FreeImage library should look like the following:APP_OPTIM := release APP_PLATFORM := android-8 APP_STL := gnustl_static APP_CPPFLAGS += -frtti APP_CPPFLAGS += -fexceptions APP_CPPFLAGS += -DANDROID APP_ABI := armeabi-v7a x86 APP_MODULES := FreeImage
The
Android.mk
file is similar to the ones we have written for the sample applications in the previous chapter, yet with a few exceptions. At the top of the file, some required variables must be defined. Let us see what theAndroid.mk
file for the FreeImage library may look like:# Android API level...