如何使用1.48.0构建 Boost (我尝试使用版本Visual Studio C++ 11)? bootstrap.bat
无法找到工具集vc11
。我将工具集vc11添加到F:\Programming\boost_1_48_0\tools\build\v2\engine\build.bat
,但收到了一条消息:
ERROR: Cannot determine the location of the VS Common Tools folder.
编辑: Ferruccio answer适用于VS 2012 Express和Boost 1.51.0。
答案 0 :(得分:39)
这个答案非常有效:
VS2012
(Visual Studio 2012 Update 2)
VS2015
(Visual Studio 2015 Update 2)简而言之
All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt
。boost_1_53_0.zip
解压缩为C:\boost153
。bootstrap.bat
bjam.exe
(可选)分步说明
All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt
。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
这很重要,我们需要将这两个路径添加到任何新的C ++项目中。
C:/boost153
添加到compiler include path
,将C:\boost153\stage\lib
添加到linker library path
。 Properties
,然后选择Configuration Properties..VC++ Directories
。请参阅下面屏幕截图中的粗体文本的两部分):
让我们运行一个简单的程序,通过添加对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;
}
结果:
Hello, world!
选中Win10 x64
+ VS2015.2
+ Boost v1.6.0
。
答案 1 :(得分:32)
我设法按照以下步骤进行构建:
它确实会产生很多关于无法检测工具包版本的警告,但无论如何都会继续。
更新:我创建了名为cclibs的GitHub仓库,这使得构建Boost和其他一些C ++库变得更加简单。
答案 2 :(得分:8)
bootstrap.bat
bjam.exe --toolset = msvc-11
答案 3 :(得分:5)
通过确认以下命令的输出来检查您的安装是否正确:
C:\>echo %VS110COMNTOOLS%
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
以下是一些简单的说明,可以在引导时删除警告:http://landoftheninja.blogspot.com/2011/11/visual-c-11-and-boost.html
不要错过他关于自动链接的后续帖子。
答案 4 :(得分:0)
vs2012 ERROR:无法确定VS Common Tools文件夹的位置。
vcvarsall.bat需要在“C:\ windows \ system32 \”中调用“reg.exe”。 如果不在搜索路径中,将导致此错误。
将C:\ windows \ system32添加到%PATH%将解决问题。
答案 5 :(得分:0)
除了上述答案,我发现BlueGo对于使用MSVC 10/11/12构建boost版本非常有帮助。您可以选择不同的配置,只需选择构建,它就可以实现。