c++ - 如何使用 VS 2019 Preview 在 Windows 10 中安装 boost

标签 c++ windows boost

我搜索了很多,但没有找到任何有用的分步指南来安装、配置和构建带有 VS 2019 预览版的 Windows 10。你们中的任何人都可以指导我完成这项任务吗?

我下载了 boost 1.70,但是当我执行 bootstrap.bat 时,它给出了以下消息:

C:\libraries\boost\boost_1_70_0>bootstrap.bat
Building Boost.Build engine

Failed to build Boost.Build engine.
Please consult bootstrap.log for further diagnostics.

C:\libraries\boost\boost_1_70_0>

此文件本身具有以下文本:
c:\libraries\boost\boost_1_70_0\tools\build\src\engine>if exist bootstrap rd /S /Q bootstrap 

c:\libraries\boost\boost_1_70_0\tools\build\src\engine>md bootstrap 

c:\libraries\boost\boost_1_70_0\tools\build\src\engine>cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib /Febootstrap\jam0  command.c compile.c constants.c debug.c execcmd.c execnt.c filent.c frames.c function.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c object.c option.c output.c parse.c pathnt.c pathsys.c regexp.c rules.c scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c builtins.c md5.c class.c cwd.c w32_getreg.c native.c modules/set.c modules/path.c modules/regex.c modules/property-set.c modules/sequence.c modules/order.c 
command.c
compile.c
constants.c
debug.c
execcmd.c
execnt.c
filent.c
frames.c
function.c
glob.c
hash.c
hdrmacro.c
headers.c
jam.c
jambase.c
jamgram.c
lists.c
make.c
make1.c
object.c
Generating Code...
Compiling...
option.c
output.c
parse.c
pathnt.c
pathsys.c
regexp.c
rules.c
scan.c
search.c
subst.c
timestamp.c
variable.c
modules.c
strings.c
filesys.c
builtins.c
md5.c
class.c
cwd.c
w32_getreg.c
Generating Code...
Compiling...
native.c
set.c
path.c
regex.c
property-set.c
sequence.c
order.c
Generating Code...

当我尝试 boost 1.68 时,我可以成功运行 bootstrap.bat,但是当我执行 b2.exe 时,它​​给了我以下消息:
warning: Did not find command for MSVC toolset. If you have Visual Studio 2017 installed you will need to specify the full path to the command, set VS150COMNTOOLS for your installation, or build from the 'Visual Studio Command Prompt for VS 2017'.

最佳答案

您目前无法使用 Preview 构建 Boost,但您可以使用刚刚发布的常规 2019。我有同样的问题。安装具有所需功能的 2019 常规版大约需要十分钟。您可以同时拥有两者。
为了将来引用,这里是我关于如何在支持 MPI 和 python 的 Windows 上构建 boost 的笔记。
使用 VS 2019 在 Windows 上构建 Boost
需要 Visual Studio 2019 非预览版,任何版本,所有 C++ 和 Windows SDK 的东西。
注意:如果您同时拥有 C++ 和 Windows SDK,请暂时从 VS Preview 中卸载它们。理想情况下,系统上只有一个编译器,因此 Boost.build 不会混淆。
接下来,假设你已经安装了 git-for-windows,执行

git clone https://github.com/boostorg/boost.git --recursive 
将 boost super 项目存储库复制到名为 /Boost/ 的未 protected 文件夹(必须不 protected !)
cd boost
现在你在 /Boost/boost
checkout 开发者分支(获取最近的更新)
git checkout develop -f
其中 -f 强制更新。
使用 Visual Studio 开发人员控制台在 boost 文件夹内运行 bootstrap 。要激活此控制台,请使用 Windows 搜索栏“在此处键入以搜索”“开发人员命令提示符”,或打开 Visual Studio 并使用顶部的搜索栏。
注意:如果您遇到访问错误,则必须激活管理 Visual Studio 开发人员控制台。
在管理模式下打开 cmd 并运行 VsDevCmd.bat,该文件可激活 Visual Studio 开发人员控制台。
bootstrap
如果您尚未这样做,请通过安装适用于最新版本 Microsoft MPI 的两个文件来安装 Microsoft MPI。
它已知与 Version 10 一起使用,需要将 SDK(.msi 文件)和非 SDK(.exe 文件)文件安装到默认位置。不要修改这些位置。
然后将/Boost/boost/目录下的project-config.jam修改为如下:
(顺便说一句,每行后面都有空格 [常规空格],甚至是空行)
# Boost.Build Configuration 
# Automatically generated by bootstrap.bat 
 
import option ; 
 
using msvc ; 
 
option.set keep-going : false ; 
 
using python ; 
 
using mpi ; 
最后两行假设您需要 mpi 和 python 支持。
现在打开 Visual Studio 开发人员控制台并导航 (cd) 到 boost 文件夹 /Boost/boost 。由于我们使用的是来自 VS 2019 的 Visual C++ 编译器,显然我们不需要 b2 install 任何东西(请参阅入门指南中的第 5.1 - 5.2 节)。那么接下来我们唯一需要的就是运行
b2 -j8 --address-model=64
选项包括
  • --toolset=14.xx [指定 vs 编译器版本 14.15 等](或 toolset 没有 -- ,有人告诉我,不确定哪个是正确的,请告诉我,对我来说是 -- )
  • -a 用于重建所有
  • 用于 8 核编译的 -j8
  • --address-model=64 (或 address-model 没有 -- ,有人告诉我,不确定哪个是正确的,请告诉我,对我来说是 -- )用于 64 位
  • > my_log.txt 最后记录构建中大量的文本输出,供以后使用(确保一切正常)。
  • 关于c++ - 如何使用 VS 2019 Preview 在 Windows 10 中安装 boost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56661801/

    相关文章:

    c++ - 如何在没有确切类型信息的情况下从 void* 转换为虚拟基类?

    windows - 如何防止软件过度安装

    windows - Windows 上的 Tomcat 日志传送到 logstash

    python - 通过 Boost 将图像从 Python 发送到 C++

    c++ - 将 pow 函数与 cpp_dec_float 结合使用

    c++ - 符合标准的编译器可以拒绝包含来自非多态类型的 dynamic_cast downcast 的代码吗?

    c++ - 具有 std::variant 和 std::visit 的 union 模板

    c++ - 神秘的笑脸出现在我的命令提示符中,这让我非常困惑,我的代码泄漏了吗?

    c++ - 使用 boost/property_tree 从具有多个元素/数组/子数组 C++ 的 json 文件中获取值

    c++ - 填充使用未指定维度初始化的 vector vector