You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在GitHub Actions macOS intel Runner中部署arm64版Boost

在Intel架构macOS(GitHub Actions macos-11)上交叉编译arm64版Boost的参数

在Intel架构的macOS机器(包括GitHub Actions的macos-11运行器)上,无法通过brew直接安装arm64版Boost二进制包,需通过源码交叉编译,具体编译参数和步骤如下:

1. 准备Boost源码

下载对应版本的Boost源码包并解压(以1.82.0版本为例):

wget https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.tar.gz
tar xzf boost_1_82_0.tar.gz
cd boost_1_82_0

2. 生成编译工具b2

执行bootstrap脚本生成b2编译工具:

./bootstrap.sh

3. 交叉编译arm64版Boost

运行b2时传入以下关键参数完成交叉编译:

./b2 \
  architecture=arm \
  address-model=64 \
  target-os=darwin \
  cxxflags="-arch arm64" \
  linkflags="-arch arm64" \
  --prefix=/usr/local/arm64-boost \
  install

参数说明:

  • architecture=arm:指定目标CPU架构为ARM
  • address-model=64:明确编译64位版本,对应arm64架构
  • target-os=darwin:指定目标系统为macOS(基于Darwin内核)
  • cxxflags="-arch arm64":告诉C++编译器生成arm64架构的目标代码
  • linkflags="-arch arm64":确保链接器使用arm64架构规则进行链接
  • --prefix:设置编译完成后的安装路径,方便后续项目引用该arm64版Boost

额外说明

  • 如果仅需要编译特定Boost库,可添加--with-<library-name>参数(例如--with-filesystem --with-thread),默认会编译所有Boost库
  • GitHub Actions的macos-11镜像已预装Xcode命令行工具,无需额外安装clang编译器;若环境异常,可执行xcode-select --install修复

内容的提问来源于stack exchange,提问作者user2022499

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 15:25:26