android NDK 编译BOOST

android NDK下 引用BOOST 也需要用NDK编译BOOST才可以 。
第一步 先生成BOOST的 B2文件 这个和之前用的普通的没区别 ./bootstrap.sh
第二步 修改boost/tools/build/v2/user-config.jam 文件 内容改成如下:

import os ;

if [ os.name ] = CYGWIN || [ os.name ] = NT {
androidPlatform = windows ;
}
else if [ os.name ] = LINUX {
androidPlatform = linux-x86 ;
}
else if [ os.name ] = MACOSX {
androidPlatform = darwin-x86 ;
}

modules.poke : NO_BZIP2 : 1 ;
NDK_ROOT = /home/ash/android-ndk-r9 ; #这个地方写你的NDK路径
using gcc : android4.6 : $(NDK_ROOT)/toolchains/arm-linux-androideabi-4.6/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-g++ :
<archiver>$(NDK_ROOT)/toolchains/arm-linux-androideabi-4.6/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ar
<ranlib>$(NDK_ROOT)/toolchains/arm-linux-androideabi-4.6/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ranlib
<compileflags>--sysroot=$(NDK_ROOT)/platforms/android-9/arch-arm
<compileflags>-I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/include
<compileflags>-I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
<compileflags>-DNDEBUG
<compileflags>-D__GLIBC__
<compileflags>-DBOOST_FILESYSTEM_VERSION=3
<compileflags>-lstdc++
<compileflags>-lgnustl_shared
<compileflags>-mthumb
<compileflags>-fno-strict-aliasing
<compileflags>-std=gnu++11
<compileflags>-O2
;

第三步

./b2 --without-python --without-mpi --without-serialization toolset=gcc-android4.6 link=static runtime-link=static target-os=linux --stagedir=android

这样就在你的BOOST目录下面生成了android文件夹 里面就是 lib静态库 然后在项目中就可以引用了

以上环境是在 Linux 32位下面实验过

文章出自http://mytestwd12.duapp.com/archives/280205.html


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值