在windows中使用Android ndk中的Boost

use*_*941 8 c++ android boost boost-build android-ndk

我试图在Eclipse中使用带有Android ndk的boost库和Windows.我试着按照这个教程

我在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.请有人帮我这个吗?

Igo*_* R. 18

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
         ;
Run Code Online (Sandbox Code Playgroud)

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

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

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

将配置放入user-config.jam后,打开cmd,cd到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左右).