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

Loo*_*oom 27 c++ boost boost-build visual-c++ visual-studio-2012

如何使用Visual Studio C++ 11构建Boost(我试过1.48.0版本)?找不到工具集.我添加了工具集vc11 但收到了一条消息:bootstrap.batvc11F:\Programming\boost_1_48_0\tools\build\v2\engine\build.bat

ERROR: Cannot determine the location of the VS Common Tools folder.
Run Code Online (Sandbox Code Playgroud)

编辑:费鲁乔 答案适用于VS 2012 Express和升压1.51.0过.

Con*_*ngo 39

这个答案非常有效:

  • VS2012 (Visual Studio 2012 Update 2)
    • VS2015(Visual Studio 2015 Update 2)
  • Windows 7 x64
    • 或Windows 10 x64
  • 提升v1.53
    • 或者提升v1.60

简而言之

  1. 打开Visual Studio 2012命令提示符.从开始菜单开始:All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt.
  2. 解压缩boost_1_53_0.zipC:\boost153.
  3. bootstrap.bat
  4. bjam.exe
  5. 在任何新的C++项目中,包括Boost库的路径,如下面的屏幕截图所示.

(可选)分步说明

  1. 安装Visual Studio 2012.
  2. 安装更新2.
  3. 从SourceForge下载Boost.
  4. 解压缩到"C:\ boost153"
  5. 使用管理员权限打开Visual Studio命令提示符.从开始菜单,它All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt.
  6. 使用更改到boost目录cd c:\boost153.
  7. bootstrap.bat.
  8. bjam.exe.这构建了所有库.
  9. 可能会有一些警告,但您可以忽略这些警告.
  10. 在大约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
    
    Run Code Online (Sandbox Code Playgroud)
  11. 这很重要,我们需要将这两个路径添加到任何新的C++项目中.

  12. 创建一个新的C++项目.
  13. 作为一对夫妇的步骤前指出,加C:/boost153compiler include pathC:\boost153\stage\liblinker library path.
  14. 右键单击项目,选择Properties,选择Configuration Properties..VC++ Directories.请参阅下面屏幕截图中的粗体文本的两部分): 在此输入图像描述
  15. 让我们运行一个简单的程序,通过添加对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;
    }
    
    Run Code Online (Sandbox Code Playgroud)
  16. 结果:

    Hello, world!
    
    Run Code Online (Sandbox Code Playgroud)

更多答案

更新2016-05-05

Win10 x64+ VS2015.2+ 检查Boost v1.6.0.


Fer*_*cio 32

我设法按照以下步骤进行构建:

  1. 打开Visual Studio命令提示符.从开始菜单开始:所有程序| Microsoft Visual Studio 11 | Native x64命令提示符.
  2. 解压缩boost_1_48_0.zip并将工作目录设置为boost_1_48_0
  3. 运行bootstrap.bat
  4. 运行bjam.exe

它确实会产生很多关于无法检测工具包版本的警告,但无论如何都会继续.

更新:我创建了名为cclibs的 GitHub repo ,这使得构建Boost和其他一些C++库变得更加简单.


Gan*_*ank 8

bootstrap.bat

bjam.exe --toolset = msvc-11


小智 5

通过确认以下命令的输出来检查您的安装是否正确:

C:\>echo %VS110COMNTOOLS%
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
Run Code Online (Sandbox Code Playgroud)

以下是一些简单的说明,可以在引导时删除警告:http://landoftheninja.blogspot.com/2011/11/visual-c-11-and-boost.html

不要错过他关于自动链接的后续帖子.