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

使用Conan构建Boost时MSVC编译失败问题求解

Boost 1.85.0 构建失败问题排查与解决

环境配置

  • Visual Studio:
Microsoft Visual Studio Professional 2022 (64-bit) - Current
Version 17.10.2
  • Conan:
Conan version 2.4.1

Conan 配置文件内容

[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.version=194
os=Windows

[conf]
tools.microsoft.msbuild:vs_version=17

问题描述

执行命令 conan install --requires=boost/1.85.0 --build=missing -v 构建Boost时,出现如下错误:

boost/1.85.0: ERROR: Package 'dcbafcaa8ac5749d5d581be6c049bc3da7c6afbe' build failed
boost/1.85.0: WARN: Build folder D:\conan_data\b\boost53872d69de0c4\b\build-debug
ERROR: boost/1.85.0: Error in build() method, line 1130
        self.run(full_command)
        ConanException: Error 1 while executing

全局Conan配置为空,且conan install --requires=gtest/1.14.0 --build=missing -v可正常运行,需解决Boost构建失败问题。

解决方案

1. 查看详细构建日志

当前错误仅提示执行失败,无具体原因,需查看Boost构建目录下的日志:

  • 进入提示的构建文件夹 D:\conan_data\b\boost53872d69de0c4\b\build-debug
  • 查找build.log或b2.log文件,里面会记录具体编译错误(如依赖缺失、参数不兼容等)

2. 修正编译器版本配置

VS 2022 17.10.2对应的MSVC编译器版本为1940,当前配置中compiler.version=194存在版本匹配问题,修改配置文件:

[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.version=1940
os=Windows

[conf]
tools.microsoft.msbuild:vs_version=17

3. 清理Conan缓存后重建

缓存中的旧文件可能引发冲突,执行以下命令清理后重新构建:

conan cache clean boost/1.85.0
conan install --requires=boost/1.85.0 --build=missing -v

4. 指定并行构建数量

默认并行构建可能因资源不足失败,手动指定并行数(根据CPU核心数调整,示例为4):

conan install --requires=boost/1.85.0 --build=missing -v -c tools.build.jobs=4

5. 确保VS环境变量加载正确

在x64 Native Tools Command Prompt for VS 2022终端中执行Conan命令,避免环境变量缺失导致编译工具调用失败

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 14:19:54