使用Visual Studio 2019命令工具构建Boost时遇问题求助
Let’s break down what’s going on here and fix it step by step:
Why This Happens
The warnings and build failure stem from outdated compiler options in Boost’s build scripts that Visual Studio 2019 no longer supports:
- The
/GZflag was deprecated long ago—VS 2019 now uses/RTC1for runtime debug checks - The
/MLdflag (old single-threaded debug runtime library option) has been completely removed from VS 2019
Step-by-Step Solutions
1. Target the Correct VS 2019 Toolset During Bootstrapping
First, try running Boost’s bootstrap script explicitly for VS 2019’s toolset (vc142):
bootstrap.bat vc142
This tells the script to use VS 2019-compatible compiler options instead of falling back to outdated defaults.
2. Manually Update Compiler Options in the Bootstrap Script
If the above doesn’t work, edit the bootstrap.bat file in your Boost root directory:
- Locate the section where
cl.exeis called to compile Boost.Jam’s source files - Replace the deprecated
/GZflag with/RTC1 - Remove the
/MLdflag and replace it with a VS 2019-supported runtime option:- Use
/MDdfor multi-threaded debug DLL runtime (the most common choice) - Use
/MTdfor multi-threaded debug static runtime
- Use
Save the changes and re-run bootstrap.bat—this should compile Boost.Jam without the deprecated/unknown option errors.
3. Upgrade to a VS 2019-Compatible Boost Version
Older Boost versions (pre-1.70) don’t include support for VS 2019’s compiler changes. Upgrading to Boost 1.70 or later will resolve these issues out of the box, as the build scripts are updated to use modern VS options.
4. Use a Precompiled Boost.Jam Binary (Alternative)
If you’d rather skip compiling Boost.Jam yourself, grab a precompiled binary built for VS 2019. Replace the auto-generated bjam.exe with this precompiled version and proceed with your Boost build.
内容的提问来源于stack exchange,提问作者Sharad Suvagiya

