Android NDK: Including boost c++ library Android NDK: Including boost c++ library android android

Android NDK: Including boost c++ library


I built the boost libraries using Boost-for-Android. Then I have in my boost/include/lib directory the android makefile boost.mk

LOCAL_PATH := $(call my-dir)# boost_date_time#include $(CLEAR_VARS)LOCAL_MODULE := boost_date_timeLOCAL_SRC_FILES := libboost_date_time-gcc-mt-1_53.ainclude $(PREBUILT_STATIC_LIBRARY)# boost_filesystem#include $(CLEAR_VARS)LOCAL_MODULE := boost_filesystemLOCAL_SRC_FILES := libboost_filesystem-gcc-mt-1_53.ainclude $(PREBUILT_STATIC_LIBRARY)# boost_thread#include $(CLEAR_VARS)LOCAL_MODULE := boost_threadLOCAL_SRC_FILES := libboost_thread-gcc-mt-1_53.ainclude $(PREBUILT_STATIC_LIBRARY)# boost_system#include $(CLEAR_VARS)LOCAL_MODULE := boost_systemLOCAL_SRC_FILES := libboost_system-gcc-mt-1_53.ainclude $(PREBUILT_STATIC_LIBRARY)# boost_program_options#include $(CLEAR_VARS)LOCAL_MODULE := boost_program_optionsLOCAL_SRC_FILES := libboost_program_options-gcc-mt-1_53.ainclude $(PREBUILT_STATIC_LIBRARY)# boost_chrono#include $(CLEAR_VARS)LOCAL_MODULE := boost_chronoLOCAL_SRC_FILES := libboost_chrono-gcc-mt-1_53.ainclude $(PREBUILT_STATIC_LIBRARY)

and my module where i use some of the boost libraries looks like this

LOCAL_PATH := $(call my-dir)# SignalServer, executable #include $(CLEAR_VARS)LOCAL_CFLAGS           := -DTIXML_USE_TICPP#LOCAL_CFLAGS           += -DDEBUGLOCAL_STATIC_LIBRARIES := boost_thread \    boost_system \    boost_filesystem \    boost_program_options \    boost_chrono \LOCAL_STATIC_LIBRARIES += ticpp \    tia \    tobicore \    tobiid \    tid \    gdfLOCAL_MODULE           := signalserverLOCAL_C_INCLUDES       := $(LOCAL_PATH)/includeLOCAL_C_INCLUDES       += $(LOCAL_PATH)/extern/includeLOCAL_C_INCLUDES       += $(LOCAL_PATH)/../boost/include/boost-1_53LOCAL_SRC_FILES        := #cpp sourceinclude $(BUILD_EXECUTABLE)

in addition I have an Android.mk where all subdir makefiles are listed

TOP_PATH := $(call my-dir)include $(TOP_PATH)/boost/lib/boost.mkinclude $(TOP_PATH)/signalserver/signalserver.mk..

and my Application.mk:

APP_PLATFORM          := android-14APP_ABI               := armeabi-v7a#APP_OPTIM             := debug#NDK_DEBUG             := 1NDK_TOOLCHAIN_VERSION := 4.6APP_STL               := gnustl_staticAPP_CPPFLAGS          := -fexceptions -frtti


Here: http://silverglint.com/boost-for-android/ you can find a simple script that lets you build a modern version of boost for android, or simply download prebuilt boost binaries.

Also included is a sample test app that shows you how to include/link the boost headers/binaries