Hi habrasoobschestvo!
Many people ask the question: “We have a bunch of C ++ libraries that we want to build for Android. How to do it?". The steps below describe the easiest way to do this.
The main requirement for raw materials is only that they are compatible with gcc and POSIX (although sometimes all sorts of cuts and hacks may be inevitable).
')
1. To build something in C ++ for Android from under Windows, you need to install at least the following:
All native build system is based on make. There is a ndk-build script that builds C ++. For it to work for your favorite library, do the following:
2. In the library folder put the file default.properties with the line target = android-8.
3. Create jni folder here and put 2 files into it:
Application.mk with this content
APP_OPTIM := release APP_PLATFORM := android-8 APP_STL := gnustl_static APP_CPPFLAGS += -frtti APP_CPPFLAGS += -fexceptions APP_ABI := armeabi armeabi-v7a APP_MODULES := MySuperProject
and Android.mk like this:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) GLOBAL_C_INCLUDES := \ $(LOCAL_PATH)/../Source \ <-- LOCAL_SRC_FILES = . .cpp jni LOCAL_MODULE := MySuperProject GLOBAL_CFLAGS := -Werror -O3 -isystem $(SYSROOT)/usr/include/ LOCAL_CFLAGS := $(GLOBAL_CFLAGS) LOCAL_C_INCLUDES := $(GLOBAL_C_INCLUDES) include $(BUILD_STATIC_LIBRARY)
4. After that, you need to run Cygwin Bash Shell, go to the folder where the jni folder is located, and run the command from the shell
ndk-build
If everything is done correctly and there are no compilation errors, then the static libMySuperProject.a will be collected (in fact, even 2 - under both targets: armeabi and armeabi-v7a) that can be linked to the project. All body movements take no more than 15 minutes.