Android NDK:包括boost c ++库

我想在我的android应用程序中使用NDK使用boost库。 我已经在这里和这里find了一些成功的故事,但我不能对我说同样的话。 我特别试图在这个链接中使用库,以及boost线程库。 在下面的代码中,我只是试图包含线程库,而不是math库。 我用来构buildboost库的过程与我附加的第一个链接非常相​​似。

到目前为止,似乎我已经成功地构build了boost库,但是当我运行ndk-build ,出现以下错误:

 Prebuilt : libboost_thread.a <= <NDK>/sources/ cp: omitting directory `path/to/ndk/sources/boost' make: *** [obj/local/armeabi/libboost_thread.a] Error 1 

显然, cp: omitting directory...不完全是一个错误。 但是除此之外,唯一得到的是下一行,这并不意味着什么。 Error 1

这是我的Android.mk文件:

 LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_STATIC_LIBRARIES := boost_thread LOCAL_LDLIBS := lboost_system-gcc-md lboost_thread-gcc-md -lgnustl_static LOCAL_LDLIBS += lboost_system-gcc-md lboost_thread-gcc-md \ -L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/armeabi \ -lgnustl_static LOCAL_SRC_FILES := #cpp_sources LOCAL_MODULE := com_example_ndkFile_CppMethods include $(BUILD_SHARED_LIBRARY) $(call import-module,boost) 

还有一个path/to/ndk/sources/boost/的Android.mk文件:

 LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:= boost_thread LOCAL_SRC_FILES:= android/lib/libboost_thread.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) include $(PREBUILT_STATIC_LIBRARY) 

和我谦卑的Application.mk文件:

 APP_ABI := armeabi armeabi-v7a APP_STL := gnustl_static APP_CPPFLAGS = -fexceptions 

我使用bjam构build了boost库。 所有libboost_###.a文件位于sources/boost/android/lib文件夹中。

我得到的错误是什么?

我使用Boost-for-Android构build了boost库。 然后,我在我的boost / include / lib目录中的android makefile boost.mk

 LOCAL_PATH := $(call my-dir) # boost_date_time # include $(CLEAR_VARS) LOCAL_MODULE := boost_date_time LOCAL_SRC_FILES := libboost_date_time-gcc-mt-1_53.a include $(PREBUILT_STATIC_LIBRARY) # boost_filesystem # include $(CLEAR_VARS) LOCAL_MODULE := boost_filesystem LOCAL_SRC_FILES := libboost_filesystem-gcc-mt-1_53.a include $(PREBUILT_STATIC_LIBRARY) # boost_thread # include $(CLEAR_VARS) LOCAL_MODULE := boost_thread LOCAL_SRC_FILES := libboost_thread-gcc-mt-1_53.a include $(PREBUILT_STATIC_LIBRARY) # boost_system # include $(CLEAR_VARS) LOCAL_MODULE := boost_system LOCAL_SRC_FILES := libboost_system-gcc-mt-1_53.a include $(PREBUILT_STATIC_LIBRARY) # boost_program_options # include $(CLEAR_VARS) LOCAL_MODULE := boost_program_options LOCAL_SRC_FILES := libboost_program_options-gcc-mt-1_53.a include $(PREBUILT_STATIC_LIBRARY) # boost_chrono # include $(CLEAR_VARS) LOCAL_MODULE := boost_chrono LOCAL_SRC_FILES := libboost_chrono-gcc-mt-1_53.a include $(PREBUILT_STATIC_LIBRARY) 

和我使用一些boost库的模块看起来像这样

 LOCAL_PATH := $(call my-dir) # SignalServer, executable # include $(CLEAR_VARS) LOCAL_CFLAGS := -DTIXML_USE_TICPP #LOCAL_CFLAGS += -DDEBUG LOCAL_STATIC_LIBRARIES := boost_thread \ boost_system \ boost_filesystem \ boost_program_options \ boost_chrono \ LOCAL_STATIC_LIBRARIES += ticpp \ tia \ tobicore \ tobiid \ tid \ gdf LOCAL_MODULE := signalserver LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_C_INCLUDES += $(LOCAL_PATH)/extern/include LOCAL_C_INCLUDES += $(LOCAL_PATH)/../boost/include/boost-1_53 LOCAL_SRC_FILES := #cpp source include $(BUILD_EXECUTABLE) 

另外我有一个Android.mk列出了所有的子目录makefiles

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

和我的Application.mk:

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

在这里: http ://silverglint.com/boost-for-android/你可以find一个简单的,无痛的新方法来构build一个现代(例如1.64.0)版本的升级为Android。 与clang和gcc一起工作。

还包括一个示例应用程序,向您展示如何使用这样构build的boost二进制文件。