Boost 1.72执行bootstrap.bat报vcunk错误,如何指定vc142工具集?
问题描述
使用Boost 1.72.0版本,系统同时安装VS2019(对应vc142工具集)和VS2022(对应vc143工具集)。执行bootstrap.bat时,脚本自动检测到VS2022,但Boost 1.72.0不支持vc143工具集,因此报错:
Found with vswhere C:\Program Files\Microsoft Visual Studio\2022\Professional
"Unknown toolset: vcunk"
You can specify the toolset as the argument, i.e.:
.\build.bat msvc
Toolsets supported by this script are: borland, como, gcc, gcc-nocygwin, intel-win32, mingw, vc12, vc14, vc141, vc142
If you have Visual Studio 2017 installed you will need to either update
the Visual Studio 2017 installer or run from VS 2017 Command Prompt
as we where unable to detect your toolset installation.
Failed to build Boost.Build engine.
需求:如何调用bootstrap.bat以指定使用vc142工具集,而非默认检测到的最新VS版本工具集?
解决方案
有两种可靠的实现方式:
方式一:通过VS2019开发者命令提示符执行
- 打开VS2019对应平台的开发者命令提示符(可在开始菜单的Visual Studio 2019文件夹中找到,如
x64 Native Tools Command Prompt for VS 2019) - 切换到Boost 1.72.0的根目录
- 直接执行
bootstrap.bat——此时环境变量已指向VS2019的vc142工具集,脚本会自动识别并使用它,无需额外参数
方式二:在普通命令行指定工具集参数
如果不想切换到开发者命令提示符,可手动指定工具集参数,步骤如下:
- 打开普通命令提示符,切换到Boost 1.72.0根目录
- 执行命令:
bootstrap.bat vc142
该命令会强制脚本使用vc142工具集编译Boost.Build引擎。若系统无法找到vc142工具链,需先手动配置VS2019的环境变量,比如运行:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64
(路径需根据你的VS2019安装目录调整,x64为目标平台,可替换为x86等),再执行bootstrap.bat vc142。
内容的提问来源于stack exchange,提问作者max_marine475
相关产品推荐
相关产品推荐

