VS 2022构建boost 1.57.0时的missing argument global-setup问题

最近要用到一个库,依赖boost,于是久违的下载了需求的最低版本1.57的boost拿来build一把,结果已开具就遇到了坑…

目前用的编译器是VS 2022的toolchain,于是打开x64 Native Tools命令行,进到boost源码路径,简单看了下说明,敲了“bootstrap.bat”,提示:

Building Boost.Build engine
cl: 命令行 warning D9035 :“GZ”选项已否决,并将在将来的版本中移除
cl: 命令行 warning D9036 :使用“RTC1”而不使用“GZ”
cl: 命令行 warning D9002 :忽略未知选项“/MLd”

Bootstrapping is done. To build, run:

    .\b2

To adjust configuration, edit 'project-config.jam'.
Further information:

    - Command line help:
    .\b2 --help

    - Getting started guide:
    http://boost.org/more/getting_started/windows.html

    - Boost.Build documentation:
    http://www.boost.org/boost-build2/doc/html/index.html

接着按提示执行b2,然后问题就来了:

D:/Projects/CLion/boost_1_57_0/tools/build/src/tools\msvc.jam:1075: in configure-really
*** argument error
* rule generate-setup-cmd ( version : command : parent : options * : cpu : global-setup : default-global-setup-options : default-setup )
* called with: ( default : D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64 : D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64 :  : i386 :  : x86 : vcvars32.bat )
* missing argument global-setup
D:/Projects/CLion/boost_1_57_0/tools/build/src/tools\msvc.jam:809:see definition of rule 'generate-setup-cmd' being called
D:/Projects/CLion/boost_1_57_0/tools/build/src/tools\msvc.jam:201: in configure
D:/Projects/CLion/boost_1_57_0/tools/build/src/tools\msvc.jam:153: in msvc.init
D:/Projects/CLion/boost_1_57_0/tools/build/src/build\toolset.jam:43: in toolset.using
D:/Projects/CLion/boost_1_57_0/tools/build/src/build\project.jam:1007: in using
project-config.jam:3: in modules.load
D:/Projects/CLion/boost_1_57_0/tools/build/src\build-system.jam:249: in load-config
D:/Projects/CLion/boost_1_57_0/tools/build/src\build-system.jam:412: in load-configuration-files
D:/Projects/CLion/boost_1_57_0/tools/build/src\build-system.jam:524: in load
D:\Projects\CLion\boost_1_57_0\tools\build\src/kernel\modules.jam:289: in import
D:\Projects\CLion\boost_1_57_0\tools\build\src/kernel/bootstrap.jam:139: in boost-build
D:\Projects\CLion\boost_1_57_0\boost-build.jam:17: in module scope

很奇怪,这么有名历史悠久的开源项目,居然会有构建问题,我用的也不是什么小众操作系统,编译器,参考下面这篇搜索出的提示,居然要手改bootstrap生成的配置文件:

https://stackoverflow.com/questions/56814269/boost-installation-missing-argument-global-setup

将project-config.jam改成如下

import option ; 
 
using msvc : 14.0 : "D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\cl.exe";

option.set keep-going : false ; 

主要就是using msvc那行,自动生成的文件貌似没有正确识别出VS2022的cl.exe位置,改成上面这样后,再次执行b2就可以正常构建了。

博主友情提示:

如您在评论中需要提及如QQ号、电子邮件地址或其他隐私敏感信息,欢迎使用>>博主专用加密工具v3<<处理后发布,原文只有博主可以看到。