构建boost 1.65.0:找不到vcvarsall.bat

构建boost 1.65.0:找不到vcvarsall.bat,boost,build,visual-studio-2017,Boost,Build,Visual Studio 2017,我尝试使用Visual Studio 2017 x64和Windows 10构建boost 1.65.0 以下是我的power shell构建脚本的外观: . ".\Invoke-CmdScript.ps1" # We expect PowerShell Version 5 if(-Not $PSVersionTable.PSVersion.Major -eq 5) { Write-Host "Expecting PowerShell Version 5" return }

我尝试使用Visual Studio 2017 x64和Windows 10构建boost 1.65.0

以下是我的power shell构建脚本的外观:

. ".\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:\thirdparty\vs2017\x64\boost_1_65_0.zip

# Check file hash
$value = Get-FileHash C:\thirdparty\vs2017\x64\boost_1_65_0.zip -Algorithm SHA256

if($value.Hash -ne "f3f5c37be45eb6516c95cd147d8aa4abb9b52121fc3eccc1fc65c4af0cf48592") {
    Write-Host "boost archive seems to be corrupted"
    return
}

# Extract file
$strFileName="$env:ProgramFiles\7-Zip\7z.exe"
If (Test-Path $strFileName){
    # Use 7-zip
    if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe")) {throw "$env:ProgramFiles\7-Zip\7z.exe needed"} 
    set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"  
    sz x C:\thirdparty\vs2017\x64\boost_1_65_0.zip -oC:\thirdparty\vs2017\x64
} Else {
    # use slow Windows stuff
    Expand-Archive C:\thirdparty\vs2017\x64\boost_1_65_0.zip -DestinationPath C:\thirdparty\vs2017\x64\boost_1_65_0
}

# Removed downloaded zip archive
Remove-Item C:\thirdparty\vs2017\x64\boost_1_65_0.zip

# Setup VS2017 x64 environment
Invoke-CmdScript -script "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" -parameters amd64

# Build
cd C:\thirdparty\vs2017\x64\boost_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

.\b2.exe --toolset=msvc-14.1 address-model=64 --build-type=complete stage -j $cpuInfo.NumberOfLogicalProcessors
简而言之,这很简单:

  • bootstrap.bat
  • b2.exe--toolset=msvc-14.1 address model=64--build type=complete stage–J8
  • 执行bootstrap.bat似乎有效。但b2会产生一些错误–未找到vcvarsall.bat:

    然而,似乎一切都很好:

    忽略这些错误消息安全吗? 有人能重现这些错误吗?

    要更新(并更正!)我以前关于构建boost的回答,下面是我在Windows上为Visual Studio和MinGw构建
    boost
    的最新注释

    Windows不直接支持boost,因此您可以下载它并将其放在任何需要的地方。
    boost用户指南建议使用boost的位置创建一个
    boost\u ROOT
    环境变量

    VisualStudio的构建 在Visual Studio工具命令提示符中:

    cd boost_1_xx_0
    call bootstrap.bat
    
    对于64位静态库(建议用于Windows):

    注意:
    boost线程
    库必须使用动态链接构建,请参见:

    对于64位动态库(仅限线程):

    如果已安装多个版本的
    Visual Studio
    ,并且希望为特定版本生成,请使用:

    • Visual Studio 2017
      工具集=msvc-14.1
    • Visual Studio 2015
      toolset=msvc-14.0
    • Visual Studio 2013
      toolset=msvc-12.0
    • Visual Studio 2012
      toolset=msvc-11.0
    • VisualStudio2010
      toolset=msvc-10.0
    注意:当我为Visual Studio 2017为64位二进制文件构建
    boost 1.65.0
    时,
    b2
    输出“构建32位:true”,但它构建了64位库

    另请注意:在
    Visual Studio 2017
    中编译
    boost 1.65.0
    包含文件时,您可能会看到以下警告:

    未知的编译器版本-请运行配置测试并报告结果

    这是因为最新版本的
    Visual Studio 2017
    \u MSC\u VER
    定义为1911,而
    boost\config\compiler\visualc.hpp
    包含:

    // 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
    
    要删除警告,请将visualc.hpp的第325行更改为:

    #if (_MSC_VER > 1911)
    
    明威大厦 确保
    mingw
    gcc
    在路径中,例如:
    C:\Qt\Tools\mingw491\u 32\bin

    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
    
    注意:对于1.61之前的boost版本,将
    bootstrap.bat gcc
    更改为
    bootstrap.bat mingw


    另请注意:
    2>&1 | tee name.txt不是必需的,但是保存日志很有用。

    注意:
    b2
    的正确工具集是
    toolset=msvc-14.1
    而不是
    toolset=msvc-15.0
    。如果你被我的旧答案误导了,我很抱歉,好的,很好,这就解决了问题-你能从你的评论中做出一个答案,这样我就可以接受你的答案吗?我很高兴它对你有效@Vertexwahn,我已经为MSVC和MinGw发布了完整的答案,谢谢。
    #if (_MSC_VER > 1911)
    
    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