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
;
当然,你需要将你的PC上NDK的正确位置放在c:/android-ndk-r8e
的位置。
此外,你可以选择更新的平台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等)。
wchar_t
相关的例程,这就是问题所在。我不知道最近的 NDK 中这个问题的状态如何。 - Igor R.armasm
工具。 - Igor R.