ndk-r20b 编译 boost 1.74。

ndk-r20b 编译 boost 1.74,这是 ndk-r20b 支持得最大 boost 版本,再大就没法编译支持了,本文介绍方法是完整编译,不需要完整编译请转移到github,boost for android 得开源项目。

1.74 boost ,安卓上面得版本编译,我这边编译了两个版本,不想编译就自己 clone 仓库。

-fPIE 编译(编程序用) 

liulilittle/boost-1.74-for-android-r20b: The maximum available static libraries on the Android platform are compiled using the Android NDK r20b toolchain + Android API 23, including libboost_context.a and libboost_coroutine.a. (github.com)

 

-fPIC 编译(动态库用) 

liulilittle/boost-1.74-for-android-r20b-fpic: The maximum available static libraries on the Android platform are compiled using the Android NDK r20b toolchain + Android API 23, including libboost_context.a and libboost_coroutine.a. (github.com)

 

先安装NDK-R20B,解压目录假定为:

/root/android/ndk/r20b

所以ANDROID_API_21版本得编译为:

/root/android/ndk/r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang++
/root/android/ndk/r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang++
/root/android/ndk/r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++
/root/android/ndk/r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++

人们必须看本人这篇文章:

Ubuntu 18.04 x86_64 上交叉编译 boost 库(ARMv7L)_armv7l 交叉编译环境-CSDN博客

1、下载 boost 1.84 的源代码访问要编译的目录,并且解压出来源代码,切入源代码根目录

2、./bootstrap.sh --with-toolset=clang

3、上一条命令生成出 b2,之后同时还会生成一个 project-config.jam 的配置文件

4、修改这个配置文件

把这段

if ! gcc in [ feature.values <toolset> ]
{
    using clang ;
}

替换成 

if ! gcc in [ feature.values <toolset> ]
{
    using clang : x86 : /root/android/ndk/r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang++ ; 
}

x86 可以直接编译出来,32位、64位,就是 amd64、intel386/intel686 机可以直接编译支持,就是 arm 得需要修改下。

在这个 nano libs/context/build/Jamfile.v2  文件之中增加架构(编译补丁):

alias asm_sources
   : asm/make_arm_aapcs_elf_gas.S
     asm/jump_arm_aapcs_elf_gas.S
     asm/ontop_arm_aapcs_elf_gas.S
   : <abi>sysv
     <address-model>32
     <architecture>arm
     <binary-format>elf
     <toolset>clang
   ;
 
alias asm_sources
   : asm/make_arm64_aapcs_elf_gas.S
     asm/jump_arm64_aapcs_elf_gas.S
     asm/ontop_arm64_aapcs_elf_gas.S
   : <abi>sysv
     <address-model>64
     <architecture>arm
     <binary-format>elf
     <toolset>clang
   ;

最后编译 boost 库:

./b2 cxxflags=-fPIC
 

确定 boost context 库是否正确的被编译,不正确编译也是会生产库(so、a)文件的,所以要自己去输出库搜下导出符号信息:

cd stage/lib

strings libboost_context.a | grep make_fcontext

objdump -D -tT -C libboost_context.a | grep make_fcontext

nm -C libboost_context.a | grep make_fcontext

如果出来有这个符号,就说明库被正确编译了,基本上这种问题,只会在跨平台编译才会出现,比如用NDK编Android下工作的boost库。

相关推荐

  1. ndk-r20b 编译 boost 1.74。

    2024-02-14 00:10:02       36 阅读
  2. Ndk编译hevc静态库

    2024-02-14 00:10:02       45 阅读
  3. 安卓交叉编译——ndk

    2024-02-14 00:10:02       10 阅读
  4. ubuntu下使用ndk编译libevnet

    2024-02-14 00:10:02       14 阅读
  5. NDK 编译(一)—— Linux 知识汇总

    2024-02-14 00:10:02       18 阅读
  6. ndk编译android系统下运行的ffmpeg配置

    2024-02-14 00:10:02       10 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-14 00:10:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-14 00:10:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-14 00:10:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-14 00:10:02       20 阅读

热门阅读

  1. 遗传算法实现

    2024-02-14 00:10:02       27 阅读
  2. 安卓termux mosh配置nvim远程开发

    2024-02-14 00:10:02       36 阅读
  3. A股上市以来涨幅排行榜

    2024-02-14 00:10:02       34 阅读
  4. 202401 卓越学院转专业-上机测试

    2024-02-14 00:10:02       32 阅读
  5. UVA489 - Hangman Judge

    2024-02-14 00:10:02       24 阅读
  6. 运维面试题

    2024-02-14 00:10:02       31 阅读
  7. 振荡器设计

    2024-02-14 00:10:02       29 阅读
  8. C语言结构体 全网最简单易懂

    2024-02-14 00:10:02       29 阅读