How to build boost for android as shared library with c++11 support

后端 未结 2 1408
生来不讨喜
生来不讨喜 2020-12-30 04:13

I am trying to build boost_1.60.0 (as shared library) for android with c++11 support. I am using the latest ndk (currently android-ndk-r10e). The build host is Windows-10. <

2条回答
  •  无人及你
    2020-12-30 04:19

    Building Boost on Linux using the NDK

    I know you're asking about Windows, but I wanted to do this on macOS and it failed with nearly the exact error. I finally broke down and did it on my linode server it worked without a problem. This says to me that they aren't really doing a good job of testing other platforms. Compiling static only on macOS works as you also discovered on Windows.

    Point of reference

    • NDK R13
    • Boost 1.62.0
    • Tested with clang++; g++ also works

    If you're wondering why I'm using clang, the Release Notes have the following message:

    GCC is no longer supported. It will not be removed from the NDK just yet, but is no longer receiving backports. It cannot be removed until after libc++ has become stable enough to be the default, as some parts of gnustl are still incompatible with Clang. It will likely be removed after that point.

    user-config.jam

    I placed this file in my home directory. Yuck.

    androidNDKRoot = /path/to/ndk-R13-standalone ;
    
    using clang : android
    :
    $(androidNDKRoot)/bin/arm-linux-androideabi-clang++
    :
    ;
    

    Modifying libtool.m4 in boost to avoid versioning of the libraries

    libtool.m4 under tools/build/src/engine/boehm_gc/libtool.m4 in the boost source has no reference to android and you'll need to change version_type=linux in the section linux*) to version_type=none. This will cause symbolic links to appear without the version number appended to the end linked to the versioned shared libraries in the output.

    Building

    Target OS MUST be android to avoid the -lrt flag being passed which will cause shared linking to fail.

    ./b2 \
       -d+2 \
       -j 4 \
       --reconfigure \
       target-os=android \
       toolset=clang-android \
       include=${ANDROID_NDK_STANDALONE}/include/c++/4.9.x \
       link=static,shared \
       variant=debug,release \
       threading=multi \
       --layout=versioned \
       --prefix=${BOOST_INSTALL_DIR} \
       install
    

提交回复
热议问题