ubuntu16.04编译boost for Android

27 篇文章 5 订阅
26 篇文章 0 订阅

https://github.com/moritz-wundke/Boost-for-Android
这个项目作者又开始更新了,建议使用这个来编译,要减小boost头文件大小的话可以使用bcp命令

下载boost源码

在官网下载指定版本的源码
http://www.boost.org/users/history/

编译boost源码

1.进入源码目录执行./bootstrap.sh生成编译工具

2.编辑project-config.jam文件,替换如下内容

# define platform name of ndk
import os ;
if [ os.name ] = CYGWIN || [ os.name ] = NT
{
    androidPlatform = windows-x86_64 ;
}
else if [ os.name ] = LINUX
{
    androidPlatform = linux-x86_64 ;
}
else if [ os.name ] = MACOSX
{
    androidPlatform = darwin-x86 ;
}

# replace with your own path
ANDROID_NDK = "/home/gavinandre/Android/Sdk/ndk-bundle" ;

# compile with gcc, you can change compiler to clang or others
using gcc : android4.9 : $(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-g++ :
<archiver>$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ar
<ranlib>$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ranlib
<compileflags>-I$(ANDROID_NDK)/platforms/android-19/arch-arm/usr/include
<compileflags>-I$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.9/include
<compileflags>-I$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
<compileflags>-I$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include
<compileflags>-fexceptions
<compileflags>-frtti
<compileflags>-fpic
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-D__ARM_ARCH_5__
<compileflags>-D__ARM_ARCH_5T__
<compileflags>-D__ARM_ARCH_5E__
<compileflags>-D__ARM_ARCH_5TE__
<compileflags>-D__ARM_ARCH_7__
<compileflags>-D__ARM_ARCH_7A__
<compileflags>-Wno-psabi
<compileflags>-march=armv7-a
<compileflags>-mtune=xscale
<compileflags>-mfloat-abi=softfp
<compileflags>-marm
<compileflags>-mthumb
<compileflags>-Os
<compileflags>-std=gnu++11
<compileflags>-fomit-frame-pointer
<compileflags>-fno-strict-aliasing
<compileflags>-finline-limit=64
<compileflags>-Wa,--noexecstack
<compileflags>-DANDROID
<compileflags>-D__ANDROID__
<compileflags>-D__ARM_EABI__
<compileflags>-DNDEBUG
<compileflags>-O2
<compileflags>-g
;

# project default compiler
project : default-build <toolset>gcc-android4.9 ;

# replace with libraries you wanna to build
libraries = --with-container --with-coroutine --with-coroutine2 --with-fiber --with-graph --with-graph_parallel --with-log --with-metaparse --with-python --with-test --with-type_erasure --with-atomic --with-date_time --with-program_options --with-chrono --with-context --with-iostreams --with-locale --with-mpi --with-serialization --with-signals --with-timer --with-wave --with-math --with-random --with-exception --with-filesystem --with-thread --with-system --with-regex --with-program_options ;

3.执行如下命令

./b2 toolset=gcc-android4.9 link=static threading=multi target-os=linux --stagedir=android_build

toolset表示指定编译工具,link表示编译成静态库,threading表示使用多线程编译,–stagedir表示指定编译文件生成目录名

4.之后等待编译完成即可

编译完成后可以在android_build目录下找到编译完的库文件
boost库在:android_build/lib下

参考:https://github.com/teamarkstudio/boost_for_android

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值