构建 boost 1.65.0:找不到 vcvarsall.bat [英] Building boost 1.65.0: vcvarsall.bat not found
问题描述
我尝试使用 Visual Studio 2017 x64 和 Windows 10 构建 boost 1.65.0.
尽管如此,似乎一切都很好:
忽略这些错误消息是否安全?有人可以重现这些错误吗?
要更新(并纠正!)我之前关于构建 boost 的答案,这里是我在 Windows 上构建 boost
的最新笔记Visual Studio
和 MinGw
.
Windows 不直接支持 boost,所以你可以下载它并放在任何你想要的地方.
boost 用户指南建议创建一个 BOOST_ROOT
环境变量与 boost 的位置.
为 Visual Studio 构建
在 Visual Studio 工具命令提示符中:
cd boost_1_xx_0调用 bootstrap.bat
对于 64 位静态库(推荐用于 Windows):
b2 -j8 toolset=msvc address-model=64 link=static threading=multi runtime-link=shared --build-type=complete stage2>&1 |三通 msvc_static_build.txt
注意:boost thread
库必须使用动态链接构建,请参阅:https://studiofreya.com/2015/05/20/the-simplest-way-of-building-boost-1-58-for-32-bit-and-64-bit-architectures-with-visual-studio/
对于 64 位动态库(仅限线程):
b2 -j8 toolset=msvc address-model=64 link=shared threading=multi runtime-link=shared --with-thread --build-type=minimal stage2>&1 |三通 msvc_thread_build.txt
如果您安装了多个版本的 Visual Studio
并且想要为特定版本构建,请使用:
Visual Studio 2017
:toolset=msvc-14.1
Visual Studio 2015
:toolset=msvc-14.0
Visual Studio 2013
:toolset=msvc-12.0
Visual Studio 2012
:toolset=msvc-11.0
Visual Studio 2010
:toolset=msvc-10.0
注意:当我为 64 位二进制文件的 Visual Studio 2017
构建 boost 1.65.0
时,b2
输出building 32 bit: true",但它构建了 64 位库...
另请注意:在 Visual Studio 2017
中编译 boost 1.65.0
包含文件时,您可能会看到警告:
未知的编译器版本 - 请运行配置测试并报告结果
这是因为最新版本的 Visual Studio 2017
将 _MSC_VER
定义为 1911 而 boostconfigcompiliervisualc.hpp
包含:
//最后已知和检查的版本是 19.10.25017 (VC++ 2017):#if (_MSC_VER > 1910)# 如果定义(BOOST_ASSERT_CONFIG)# error "未知的编译器版本 - 请运行配置测试并报告结果"# 别的# pragma message("未知编译器版本 - 请运行配置测试并报告结果")# 万一#万一
要删除警告,请将 visualc.hpp
的第 325 行更改为:
#if (_MSC_VER > 1911)
为 MinGw 构建
确保 mingw
或 gcc
在路径中,例如:C:QtToolsmingw491_32in
cd boost_1_xx_0调用 bootstrap.bat gccb2工具集=gcc链接=共享线程=多--build-type=完成阶段2>&1 |tee mingw_build.txt
<块引用>
注意:对于 1.61 之前的 boost 版本,将 bootstrap.bat gcc
更改为 bootstrap.bat mingw
另请注意:2>&1 |tee name.txt
不是必需的,但保留日志很有用...
I tried to build boost 1.65.0 using Visual Studio 2017 x64 and Windows 10.
This is how my power shell build script looks like:
. ".Invoke-CmdScript.ps1"
# We expect PowerShell Version 5
if(-Not $PSVersionTable.PSVersion.Major -eq 5) {
Write-Host "Expecting PowerShell Version 5"
return
}
# Now download boost 1.65.0
Invoke-WebRequest http://dl.bintray.com/boostorg/release/1.65.0/source/boost_1_65_0.zip -OutFile C: hirdpartyvs2017x64oost_1_65_0.zip
# Check file hash
$value = Get-FileHash C: hirdpartyvs2017x64oost_1_65_0.zip -Algorithm SHA256
if($value.Hash -ne "f3f5c37be45eb6516c95cd147d8aa4abb9b52121fc3eccc1fc65c4af0cf48592") {
Write-Host "boost archive seems to be corrupted"
return
}
# Extract file
$strFileName="$env:ProgramFiles7-Zip7z.exe"
If (Test-Path $strFileName){
# Use 7-zip
if (-not (test-path "$env:ProgramFiles7-Zip7z.exe")) {throw "$env:ProgramFiles7-Zip7z.exe needed"}
set-alias sz "$env:ProgramFiles7-Zip7z.exe"
sz x C: hirdpartyvs2017x64oost_1_65_0.zip -oC: hirdpartyvs2017x64
} Else {
# use slow Windows stuff
Expand-Archive C: hirdpartyvs2017x64oost_1_65_0.zip -DestinationPath C: hirdpartyvs2017x64oost_1_65_0
}
# Removed downloaded zip archive
Remove-Item C: hirdpartyvs2017x64oost_1_65_0.zip
# Setup VS2017 x64 environment
Invoke-CmdScript -script "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCAuxiliaryBuildvcvarsall.bat" -parameters amd64
# Build
cd C: hirdpartyvs2017x64oost_1_65_0
Invoke-CmdScript -script "bootstrap.bat"
$cpuInfo = Get-CimInstance -ClassName 'Win32_Processor' `
| Select-Object -Property 'DeviceID', 'Name', 'NumberOfCores', 'NumberOfLogicalProcessors';
Write-Host $cpuInfo.NumberOfLogicalProcessors
.2.exe --toolset=msvc-14.1 address-model=64 --build-type=complete stage -j $cpuInfo.NumberOfLogicalProcessors
To boil it down – it simple does:
bootstrap.bat
b2.exe --toolset=msvc-14.1 address-model=64 --build-type=complete stage –j 8
Execution bootstrap.bat seems to work. But b2 yields some errors – vcvarsall.bat not found:
Nevertheless, it seems that everything is build fine:
Is it safe to ignore those error messages? Can someone reproduce those errors?
To update (and correct!) my previous answers on building boost, here are my latest notes for building boost
on Windows for both Visual Studio
and MinGw
.
Windows does not directly support boost, so you can download it and put it wherever you want.
The boost user guide recommends creating a BOOST_ROOT
environment variable with the location of boost.
Building for Visual Studio
In a Visual Studio tools Command Prompt:
cd boost_1_xx_0
call bootstrap.bat
For 64 bit static libraries (recommended for Windows):
b2 -j8 toolset=msvc address-model=64 link=static threading=multi runtime-link=shared --build-type=complete stage
2>&1 | tee msvc_static_build.txt
Note: the boost thread
library must be built with dynamic linking see: https://studiofreya.com/2015/05/20/the-simplest-way-of-building-boost-1-58-for-32-bit-and-64-bit-architectures-with-visual-studio/
For 64 bit dynamic library (thread only):
b2 -j8 toolset=msvc address-model=64 link=shared threading=multi runtime-link=shared --with-thread --build-type=minimal stage
2>&1 | tee msvc_thread_build.txt
If you have multiple versions of Visual Studio
installed and want to build for a specific version then use:
Visual Studio 2017
:toolset=msvc-14.1
Visual Studio 2015
:toolset=msvc-14.0
Visual Studio 2013
:toolset=msvc-12.0
Visual Studio 2012
:toolset=msvc-11.0
Visual Studio 2010
:toolset=msvc-10.0
Note: when I built
boost 1.65.0
forVisual Studio 2017
for 64 bit binaries,b2
output "building 32 bit: true", but it built 64 bit libraries...
Also note: whilst compiling a boost 1.65.0
include file in Visual Studio 2017
you may see the warning:
Unknown compiler version - please run the configure tests and report the results
This is because the latest version of Visual Studio 2017
defines _MSC_VER
as 1911 whilst boostconfigcompiliervisualc.hpp
contains:
// last known and checked version is 19.10.25017 (VC++ 2017):
#if (_MSC_VER > 1910)
# if defined(BOOST_ASSERT_CONFIG)
# error "Unknown compiler version - please run the configure tests and report the results"
# else
# pragma message("Unknown compiler version - please run the configure tests and report the results")
# endif
#endif
To remove the warning, change line 325 of visualc.hpp
to:
#if (_MSC_VER > 1911)
Building for MinGw
Ensure that mingw
or gcc
is in the path, e.g.: C:QtToolsmingw491_32in
cd boost_1_xx_0
call bootstrap.bat gcc
b2 toolset=gcc link=shared threading=multi --build-type=complete stage
2>&1 | tee mingw_build.txt
Note: for boost versions prior to 1.61 change
bootstrap.bat gcc
tobootstrap.bat mingw
Also note: 2>&1 | tee name.txt
isn't necessary, but it's useful to keep a log...
这篇关于构建 boost 1.65.0:找不到 vcvarsall.bat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!