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

后端 未结 2 1390
生来不讨喜
生来不讨喜 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
    
    0 讨论(0)
  • 2020-12-30 04:23

    A relevant information is here (Boost for Android), where they have been able to successfully build the shared libraries, but it seems that the resulting files have a version suffix which android can't handle. Also one can't just rename the binary because the file name is hardcoded in it. One way out, as per the last post, is to set the variable version_type to none (version_type=none) in the linux section of file. In your case, the build setup could be a little different, but it may be worthwhile to take a look at the changes they made at that discussion.

    0 讨论(0)
提交回复
热议问题