【问题标题】:Using Boost in android ndk with windows在带有 Windows 的 android ndk 中使用 Boost
【发布时间】:2013-07-14 03:04:56
【问题描述】:

我正在尝试在带有 Windows 的 Eclipse 中使用带有 Android ndk 的 boost 库。我试着关注this tutorial

我被 cygwin 中的“bjam”命令卡住了。

bjam --without-python --without-serialization toolset=gcc-android4.4.3 link=static runtime-link=static target-os=linux --stagedir=android

错误:找不到 bjam 命令。

什么是bjam?我也沿 ndk r8e 使用了 boost 1.53。有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: android c++ boost android-ndk boost-build


    【解决方案1】:

    Android NDK 不再依赖于 Cygwin,因此您可以在 Windows 命令提示符 (cmd) 中使用 NDK 构建 Boost。

    为了让Boost.Build 找到NDK,编辑boost\tools\build\v2\user-config.jam 文件并附加以下文本:

    import os ;
    
    androidNDKRoot = C:/android-ndk-r8e ; # put the relevant path
     using gcc : android :
         $(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-g++ :
         <compileflags>--sysroot=$(androidNDKRoot)/platforms/android-9/arch-arm
         <compileflags>-mthumb
         <compileflags>-Os
         <compileflags>-fno-strict-aliasing
         <compileflags>-O2
         <compileflags>-DNDEBUG
         <compileflags>-g
         <compileflags>-lstdc++
         <compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.7/include
         <compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi/include
         <compileflags>-D__GLIBC__
         <compileflags>-D_GLIBCXX__PTHREADS
         <compileflags>-D__arm__
         <compileflags>-D_REENTRANT
         <archiver>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-ar
         <ranlib>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-ranlib
             ;
    

    当然,您必须将 NDK 的正确位置放在您的 PC 上,而不是 c:/android-ndk-r8e

    此外,您可以选择更新的平台 API,而不是 android-9

    另请注意,NDK 提供了几个工具链,并且上述设置指向 gcc-4.7。如果您更喜欢使用其他工具链构建 boost,请将 arm-linux-androideabi-4.7 更改为相关路径。

    将配置放入 user-config.jam 后,打开 cmdcd 到 Boost 所在的目录,然后调用 bootstrap。然后像这样调用b2(例如):

    b2 --without-python --without-serialization threading=multi link=static runtime-link=static toolset=gcc-android target-os=linux threadapi=pthread --stagedir=android stage

    更新:截至 2015 年 11 月,较旧的 NDK 工具链似乎与较新的 Boost 版本存在问题,导致编译器崩溃,因此请考虑使用更新的编译器。为此,只需将上述脚本中每出现一次 4.7 更改为 4.9。此外,值得使用更新的 Android API 进行编译(例如,andoroid-9 -> andoroid-16 左右)。

    【讨论】:

    • D:\android_ndk_with_boost\android-ndk-r8e\sources\boost_1_53_0\tools\build\v2>b2 --without-python --without-serialization threading=multi link=static runtime-link =static toolset=gcc-android4.6 target-os=linux threadapi=pthread --stagedir=an droid D:/android_ndk_with_boost/android-ndk-r8e/sources/boost_1_53_0/tools/build/v2/to ols\gcc.jam :78: 在 gcc.init 中来自模块 gcc 错误:工具集 gcc 初始化:错误:提供的命令 'D:/android_ndk_with_boost/android-ndk-r8e/toolchains/ar m-linux-androideabi-4.6/prebuilt/windows/bin/arm -linux-androideabi-g++' 没有找到
    • @user2508941 什么是“toolset=gcc-android4.6”?您是如何在 user-config.jam 中定义的? (使用 pastebin.com 或类似网站来输入错误。)
    • 这是一个语法错误...因为我们在 android ndk r8e(4.4.3 4.6 和 4.7)中...将您给我的代码中的 4.7 更改为 4.6 伙计..跨度>
    • 路径是一样的,只是4.7到4.6的变化
    • @user2508941 首先,我建议您尝试使用我发布的配置文件,并像我的示例一样调用b2。你不能设置 "toolset=gcc-android4.6" 因为using 部分没有 "android4.6" 版本,所以要么保留它 "toolset=gcc-android" 要么学习 Boost.Build 语法:boost.org/boost-build2/doc/html/bbv2/overview/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-23
    • 1970-01-01
    • 2015-08-10
    • 2020-10-01
    相关资源
    最近更新 更多