Android-compiled boost dynamic library

Source: Internet
Author: User

There is an android project that uses the boost Standard c ++ library. The Boost library is a portable C ++ library that provides source code and serves as a backup for the standard library, it is one of the engines of the C ++ standardization process, so I want to transplant it to the android system for compilation. Download boost1.52 from the Internet and write makefile... Compilation, encountered numerous compilation errors. Turn to google network, and finally found a good stuff: A git project that compiled boost code through NDK: https://github.com/MysticTreeGames/Boost-for-Android here is the use of NDK to compile boost but it must be useful to me .. After some hard work, the compilation was successful! The main process is recorded below: 1. Download the boost source code: boost for Android Boost for android is a set of tools to compile the main part of the Boost C ++ Libraries for the Android platform. currently supported boost versions are 1.45.0, 1.48.0 and 1.49.0. so download the latest version 1.49, after the download is complete patch 2, download the patch code https://github.com/MysticTreeGames/Boost-for-Android/tree/master/patches/boost-1_49_0 3, patch code boost_000049_0.tar.bz2 put in the android external unzip: Tar-xjvf external/plugin place the boost-1_49_0.patch in the root directory of external \ boost_000049_0 execute: patch-Np1-d external/boost_000049_0 <external/boost_000049_0/boost-1_49_0.patch 4. Write the makefile file for boost, android. mk [cpp] LOCAL_PATH: = $ (call my-dir) common_SRC_FILES: = \ libs/thread/src/pthread/thread. cpp \ libs/thread/src/pthread/once. cpp \ common_SRC_FILES + = \ libs/filesystem/v3/src/codecvt_error_category. Cpp \ libs/filesystem/v3/src/operations. cpp \ libs/filesystem/v3/src/path. cpp \ libs/filesystem/v3/src/path_traits.cpp \ libs/filesystem/v3/src/portability. cpp \ libs/filesystem/v3/src/Users \ libs/system/src/error_code.cpp \ libs/system/src/local_free_on_destruction \ include $ (CLEAR_VARS) LOCAL_MODULE: = boost LOCAL_SRC_FILES: = $ (common_SRC_FILES) LOCAL_PATH: = $ (call my-dir) Common_SRC_FILES: = \ libs/thread/src/pthread/thread. cpp \ libs/thread/src/pthread/once. cpp \ common_SRC_FILES + = \ libs/filesystem/v3/src/codecvt_error_category.cpp \ libs/filesystem/v3/src/operations. cpp \ libs/filesystem/v3/src/path. cpp \ libs/filesystem/v3/src/path_traits.cpp \ libs/filesystem/v3/src/portability. cpp \ libs/filesystem/v3/src/utf8_codecvt_facet.cpp \ libs/system/src/error_code.cpp \ li Bs/system/src/local_free_on_destruction \ include $ (CLEAR_VARS) LOCAL_MODULE: = libboostLOCAL_SRC_FILES :=$ (common_SRC_FILES) [cpp] view plaincopyprint? Prebuilt_stdcxx_PATH: = prebuilts/ndk/current/sources/cxx-stl/gnu-libstdc ++ LOCAL_C_INCLUDES :=\$ (LOCAL_PATH)/boost \ $ (prebuilt_stdcxx_PATH) /include \ $ (prebuilt_stdcxx_PATH)/libs/$ (TARGET_CPU_ABI)/include/\ LOCAL_C_INCLUDES :=\$ (optional)/include \ $ (prebuilt_stdcxx_PATH)/libs/$ (TARGET_CPU_ABI) /include/\ $ (prebuilt_supccxx_PATH)/include LOCAL_CFLAGS + =-fvisibility = hidden-lpthread LOCAL_CPPFLAGS + =-fexceptions-frtti LOCAL_SHARED_LIBRARIES: = libc libstdc ++ libstlport LOCAL_LDFLAGS + =-L $ (bytes)/libs/$ (TARGET_CPU_ABI)-lgnustl_static-lsupc ++ Signature: = optional include $ (BUILD_SHARED_LIBRARY) usage: = prebuilts/ndk/current/sources/cxx-stl/gnu-libstdc ++ LOCAL_C_INCLUDES: =\$ (LOCAL_PATH)/boost \ $ (prebuilt_stdcxx_PATH)/include \ $ (prebuilt_stdcxx_PATH) /libs/$ (TARGET_CPU_ABI)/include/\ LOCAL_C_INCLUDES :=\$ (prebuilt_stdcxx_PATH)/include \ $ (prebuilt_stdcxx_PATH)/libs/$ (TARGET_CPU_ABI) /include/\ $ (prebuilt_supccxx_PATH)/include LOCAL_CFLAGS + =-fvisibility = hidden-lpthreadLOCAL_CPPFLAGS + =-fexceptions-frtti LOCAL_SHARED_LIBRARIES: = libc libstdc ++ libstlport LOCAL_LDFLAGS + =-L $ (bytes)/libs/$ (TARGET_CPU_ABI)-lgnustl_static-lsupc + + Bytes: = optionalinclude $ (BUILD_SHARED_LIBRARY) [cpp] The most important part is the final compilation of the red text above: target thumb C ++: libboost <= external/boost_000049_0/libs/thread/src/pthread/thread. cpptarget thumb C ++: libboost <= external/boost_000049_0/libs/thread/src/pthread/once. cpptarget thumb C ++: libboost <= external/boost_000049_0/libs/filesystem/v3/src/codecvt_error_category.cpptarget thumb C ++: libboost <= external/boost_000049_0/libs/filesystem/v3/src/operations. cpptarget thumb C ++: libboost <= external/boost_000049_0/libs/filesystem/v3/src/path. cpptarget thumb C ++: libboost <= external/boost_000049_0/libs/filesystem/v3/src/path_traits.cpptarget thumb C ++: libboost <= external/boost_000049_0/libs/filesystem/v3/src/portability. cpptarget thumb C ++: libboost <= external/boost_000049_0/libs/filesystem/v3/src/utf8_codecvt_facet.cpptarget thumb C ++: libboost <= external/boost_000049_0/libs/system/src/sharesharedlib: libboost (out/target/product/godbox/obj/SHARED_LIBRARIES/libboost_intermediates/LINKED/libboost. so) target Symbolic: libboost (out/target/product/godbox/symbols/system/lib/libboost. so) target Strip: libboost (out/target/product/godbox/obj/lib/libboost. so) Install: out/target/product/godbox/system/lib/libboost. so successfully generates libboost. so Library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.