【问题标题】:How to compile Boost 1.61 for Android NDK 11如何为 Android NDK 11 编译 Boost 1.61
【发布时间】:2016-06-07 12:36:30
【问题描述】:

我想用 NDK 11 安装 compile Boost 1.61 with clang 3.6 for android 但这个软件:https://github.com/moritz-wundke/Boost-for-Android 没有更新,不支持这个版本。

我想知道有没有人做到这一点!

谢谢!

【问题讨论】:

    标签: android c++ boost


    【解决方案1】:

    在 Windows64 下为 Android-21 构建 boost_1_62_0。

    假设 NDK 安装到 C:\Programs\Android\sdk\ndk-bundle 并在 c:\boost_1_62_0 中提升。

    安装mingw:using msys2-x86_64 from MSYS2

    从 mingw 提示符安装构建工具(类似这样):

    $ pacman -S gcc binutils
    

    C:\boost_1_62_0\ 中创建带有这样文本内容的android.clang.jam 文件:

    import os ;
    local AndroidNDKRoot = C:/Programs/Android/sdk/ndk-bundle ;
    using clang : android
    :
    C:/Programs/Android/toolchain21/bin/clang++
    :
    <compileflags>-fexceptions
    <compileflags>-frtti
    <compileflags>-fpic
    <compileflags>-ffunction-sections
    <compileflags>-funwind-tables
    <compileflags>-Wno-psabi
    <compileflags>-march=armv7-a
    <compileflags>-mfloat-abi=softfp
    <compileflags>-mfpu=vfpv3-d16
    <compileflags>-fomit-frame-pointer
    <compileflags>-fno-strict-aliasing
    <compileflags>-finline-limit=64
    <compileflags>-I$(AndroidNDKRoot)/platforms/android-21/arch-arm/usr/include
    <compileflags>-Wa,--noexecstack
    <compileflags>-DANDROID
    <compileflags>-D__ANDROID__
    <compileflags>-DNDEBUG
    <compileflags>-O2
    #<compileflags>-g
    <compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.9/include
    <compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include
    <architecture>arm
    <compileflags>-fvisibility=hidden
    <compileflags>-fvisibility-inlines-hidden
    <compileflags>-fdata-sections
    <cxxflags>-D__arm__
    <cxxflags>-D_REENTRANT
    <cxxflags>-D_GLIBCXX__PTHREADS
    ;
    

    从 mingw 提示设置提升:

    $ export NDK=/c/Programs/Android/sdk/ndk-bundle
    $ echo ensure msi-installed Python is on path (not msys version):
    $ export PATH=/c/Python27:$PATH
    $ $NDK/build/tools/make_standalone_toolchain.py --arch arm --api 21 --install-dir /c/Programs/Android/toolchain21
    $ ./bootstrap.sh --with-toolset=gcc
    $ ./b2 --user-config=android.clang.jam threading=multi link=static \
    runtime-link=static toolset=clang-android target-os=linux \
    threadapi=pthread --stagedir=android --with-chrono \
    --with-program_options --with-system --with-thread --with-random \
    --with-regex
    

    【讨论】:

      【解决方案2】:

      对我来说是这样的

      1. 我创建了一个clang独立工具链https://developer.android.com/ndk/guides/standalone_toolchain.html
      2. 我将 PATH 设置为 PATH=/your/path/ndk/toolchain/bin
      3. 运行./bootstrap.sh --with-toolset=clang
      4. ./b2 toolset=clang cxxflags="-stdlib=libc++" threading=multi threadapi=pthread link=shared runtime-link=shared -j 6
      5. 我将它链接到我的项目中

      我看过这些页面

      Compile and use boost for Android NDK R10e

      http://nolimitsdesigns.com/game-design/how-to-build-boost-for-the-android-ndk-llvm/

      【讨论】:

        【解决方案3】:

        是的,您提到的存储库显然不再维护。作者似乎也没有回复任何有关该主题的邮件。如果您看一下,您会发现那里支持的每个新的 boost 版本都需要大量工作(配置文件中的许多特殊标志)。这大概就是他没有时间再维护它的原因了。 我还尝试使用 fork 更新到 1.64,但在收到无数错误消息后放弃了,而是使用了基于 rystax 脚本的不同方法。它很简单,几乎适用于任何版本。您可以在此处找到详细信息和脚本(执行简单且轻松):http://silverglint.com/boost-for-android/ 适用于 clang 和 gcc。

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

        【讨论】:

          猜你喜欢
          • 2015-08-10
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-02-22
          • 1970-01-01
          相关资源
          最近更新 更多