C++ 使用MSVC 11进行Boost编译(VS 2012)

C++ 使用MSVC 11进行Boost编译(VS 2012),c++,visual-c++,boost,visual-studio-2012,boost-build,C++,Visual C++,Boost,Visual Studio 2012,Boost Build,如何使用构建Boost(我尝试过的版本)引导.bat找不到工具集vc11。我将工具集vc11添加到F:\Programming\boost\u 1\u 48\u 0\tools\build\v2\engine\build.bat,但收到一条消息: ERROR: Cannot determine the location of the VS Common Tools folder. 编辑:Ferruccio也适用于VS 2012 Express和Boost 1.51.0。我通过以下步骤成功构建了

如何使用构建Boost(我尝试过的版本)<代码>引导.bat找不到工具集
vc11
。我将工具集vc11添加到
F:\Programming\boost\u 1\u 48\u 0\tools\build\v2\engine\build.bat
,但收到一条消息:

ERROR: Cannot determine the location of the VS Common Tools folder.

编辑:Ferruccio也适用于VS 2012 Express和Boost 1.51.0。

我通过以下步骤成功构建了它:

  • 打开Visual Studio命令提示符。从“开始”菜单可以看到:所有程序| Microsoft Visual Studio 11 |本机x64命令提示符
  • 解压缩boost_1_48_0.zip并将工作目录设置为boost_1_48_0
  • 运行bootstrap.bat
  • 运行bjam.exe
  • 它确实会生成很多关于无法检测工具包版本的警告,但它仍然会继续


    <强> Update:我创建了GITHUB RePO,这使得构建Boost和其他C++库更为简单。

    < P>检查以下命令的输出:检查您的安装是否正确:

    C:\>echo %VS110COMNTOOLS%
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
    
    以下是一些在引导时消除警告的简单说明:


    不要错过他关于自动链接的后续文章。

    这个答案适用于:

    • VS2012
      (Visual Studio 2012更新2)
      • VS2015
        (Visual Studio 2015更新2)
    • Windows 7 x64
      • 或Windows 10 x64
    • Boost v1.53
      • 或Boost v1.60
    简而言之

  • 打开Visual Studio 2012命令提示符。从“开始”菜单中,其:
    所有程序..Microsoft Visual Studio 2012..Visual Studio工具..x64本机工具命令提示符
  • boost\u 1\u 53\u 0.zip解压缩到
    C:\boost153
  • 运行
    bootstrap.bat
  • 运行
    bjam.exe
  • 在任何新的C++项目中,包括下面的截图的Boost库的路径。
  • (可选)逐步说明

  • 安装Visual Studio 2012
  • 安装更新2
  • 下载
  • 解压缩到“C:\boost153”
  • 以管理员权限打开Visual Studio命令提示符。从“开始”菜单中,显示其
    所有程序..Microsoft Visual Studio 2012..Visual Studio Tools..x64本机工具命令提示符
  • 使用
    cd c:\boost153
    切换到boost目录
  • 运行
    bootstrap.bat
  • 运行
    bjam.exe
    。这将构建所有库
  • 可能会有一些警告,但您可以忽略这些警告
  • 大约5分钟后完成编译时,它会声明:

    The Boost C++ Libraries were successfully built!
    The following directory should be added to compiler include paths:
       C:/boost153
    The following directory should be added to linker library paths:
       C:\boost153\stage\lib
    
  • >P>这很重要,我们需要将这两条路径添加到任何新的C++项目。

    < LI>创建一个新的C++项目。
  • 如前几步所述,将
    C:/boost153
    添加到
    编译器包含路径中,并将
    C:\boost153\stage\lib
    添加到
    链接器库路径中
    
  • 右键单击项目,选择
    属性
    ,选择
    配置属性..VC++目录
    。请参见以下屏幕截图中粗体文本的两部分):
  • 让我们运行一个简单的程序,通过添加对
    foreach
    循环的支持来展示boost的威力:

    // Source code below copied from:   
    // http://www.boost.org/doc/libs/1_53_0/doc/html/foreach.html
    #include "stdafx.h"
    
    #include <string>
    #include <iostream>
    #include <conio.h> // Supports _getch()
    #include <boost/foreach.hpp>
    
    int main()
    {
        std::string hello( "Hello, world!" );
    
        BOOST_FOREACH( char ch, hello )
        {
            std::cout << ch;
        }
    
        _getch();
        return 0;
    }
    
  • 更多答案
    更新2016-05-05
    使用Win10 x64检查错误:无法确定VS公用工具文件夹的位置

    vcvarsall.bat需要调用“C:\windows\system32\”中的“reg.exe”。 如果不在搜索路径中,将导致此错误

    将C:\windows\system32添加到%PATH%将解决此问题。

    bootstrap.bat


    bjam.exe--toolset=msvc-11

    除了上面的答案,我发现使用msvc 10/11/12构建boost版本非常有用。您可以选择不同的配置,只需选择build,就可以了

    多亏了这一点,如果您通过
    (HKCU | | HKLM)\Software\Microsoft\Command Processor:reg_sz AutoRun
    执行
    doskey.exe
    ,比boost doc的implyware要容易得多。生成导致
    doskey
    崩溃,生成失败。我已提交。此构建并非所有库要构建其他所需库,请向
    bjam
    b2
    命令添加选项。一些常见的交换机正在为静态/共享、x32/x64等或自boost 1.47.0以来构建库--toolset=msvc-11
    。这个答案似乎比从devshell重新运行引导程序并忽略上传警告要正确得多。
    Hello, world!