在带有 Windows 的 android ndk 中使用 Boost [英] Using Boost in android ndk with windows

查看:16
本文介绍了在带有 Windows 的 android ndk 中使用 Boost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在带有 Windows 的 Eclipse 中使用带有 Android ndk 的 boost 库.我尝试遵循 本教程

I am trying to use boost library with Android ndk in Eclipse with Windows. I tried to follow this tutorial

我被 cygwin 中的bjam"命令卡住了.

I am stuck in the step with "bjam" command in cygwin.

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

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

错误:找不到 bjam 命令.

Error: bjam command not found.

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

What is bjam? Also I used the boost 1.53 along ndk r8e. Can someone help me with this please?

推荐答案

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

Android NDK is no longer dependent on Cygwin, so you can build Boost with the NDK from within Windows command prompt (cmd).

为了使 Boost.Build 找到 NDK,编辑 boost oolsuildv2user-config.jam 文件并附加以下文本:

In order to make Boost.Build find the NDK, edit boost oolsuildv2user-config.jam file and append the following text:

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.

Certainly, instead of c:/android-ndk-r8e you have to put the right location of the NDK on your PC.

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

Besides, you can select more recent platform API, instead of android-9.

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

Also note that the NDK supplies several tool-chains, and the above settings point to gcc-4.7. If you prefer to build boost with some other tool-chain, change arm-linux-androideabi-4.7 to the relevant path.

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

After you've put the configuration in user-config.jam, open cmd, cd to the directory where Boost resides, and invoke bootstrap. Then invoke b2 like this (for example):

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 左右).

UPDATE: As of 11/2015, older NDK toolchains seem to have issues with the newer Boost versions, causing compiler crash, so consider using a more recent compiler. To do this, just change every 4.7 occurrence in the above script to 4.9. Also, it's worth compiling with a more recent Android API (eg. andoroid-9 -> andoroid-16 or so).

这篇关于在带有 Windows 的 android ndk 中使用 Boost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆