交叉编译 boost

1. 交叉编译过程

本文以 Ubuntu 22.04.5 LTS Desktop 作为 HostARMv7 嵌入式设备为 Target,说明 boost_1_74_0.tar.bz2 的交叉编译过程。

wget https://archives.boost.io/release/1.74.0/source/boost_1_74_0.tar.bz2
tar xf boost_1_74_0.tar.bz2
cd boost_1_74_0
  • 安装交叉编译器
sudo apt update
sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
  • 配置构建系统
    Boost 可以通过 B2CMake 两种方式构建。官方推荐使用 B2,本文也只讨论 B2 构建方式。这里选择性的编译一些需要的 lib,而不是整个 boost:
./bootstrap.sh --with-libraries=thread,filesystem,log,program_options,date_time,test --prefix=`pwd`/_install

修改当前目录下生成的 project-config.jam

-    using gcc ; 
+    using gcc : arm : arm-linux-gnueabihf-g++ ; 
  • 编译和安装
./b2
./b2 install

编译生成 lib 文件的临时存放目录stage./b2 installheader, lib 等一系列文件安装到 _install 目录。

更多通过 B2 构建 Boost 资料可参考:

https://www.boost.org/doc/user-guide/getting-started.html
https://www.bfgroup.xyz/b2/manual/release/index.html#b2.tasks.crosscompile
https://www.bfgroup.xyz/b2/manual/release/index.html#b2.overview.configuration

2. 参考资料

[1] https://www.boost.org/
[2] Getting Started
[3] https://www.bfgroup.xyz/b2/
[4] https://www.bfgroup.xyz/b2/manual/release/index.html#b2.tasks.crosscompile
[5] https://www.bfgroup.xyz/b2/manual/release/index.html#b2.overview.configuration

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值