详细教程可以参考:http://www.boost.org/doc/libs/1_55_0/more/getting_started/windows.html#id32
1.下载boost
http://sourceforge.net/projects/boost/?source=typ_redirect
2.解压到目标文件夹
我这里解压到D:\work_files
3.编译库
在CMD下面,进入D:\work_files\boost_1_55_0
输入下面语句
boostrap
.\b2
注意如果编译出来版本不对的话,就得自己写个批处理文件
内容如下:
bjam toolset=msvc-11.0 variant=release threading=multi link=static define=_SECURE_SCL=0 define=_HAS_ITERATOR_DEBUGGING=0
bjam toolset=msvc-11.0 variant=debug threading=multi link=static
命名为boost_build.bat,放在D:\work_files\boost_1_55_0目录下,然后在cmd中执行它
具体选项bjam flags
Feature | Allowed values | Notes |
---|---|---|
variant | debug,release | |
link | shared,static | Determines if Boost.Build creates shared or static libraries |
threading | single,multi | Cause the produced binaries to be thread-safe. This requires proper support in the source code itself. |
address-model | 32,64 | Explicitly request either 32-bit or 64-bit code generation. This typically requires that your compiler is appropriately configured. Please refer to the section called “C++ Compilers” and your compiler documentation in case of problems. |
toolset | (Depends on configuration) | The C++ compiler to use. See the section called “C++ Compilers” for a detailed list. |
include | (Arbitrary string) | Additional include paths for C and C++ compilers. |
define | (Arbitrary string) | Additional macro definitions for C and C++ compilers. The string should be either SYMBOL or SYMBOL=VALUE |
cxxflags | (Arbitrary string) | Custom options to pass to the C++ compiler. |
cflags | (Arbitrary string) | Custom options to pass to the C compiler. |
linkflags | (Arbitrary string) | Custom options to pass to the C++ linker. |
runtime-link | shared,static | Determines if shared or static version of C and C++ runtimes should be used. |
具体版本
Product name | Codename | Version number | cl.exe version | Supported .NET Framework versions | Release date |
---|---|---|---|---|---|
Visual Studio 4.0 | N/A | 4.0 | N/A | N/A | April 1995 |
Visual Studio 97 | Boston | 5.0 | N/A | N/A | February 1997 |
Visual Studio 6.0 | Aspen | 6.0 | 12.00 | N/A | June 1998 |
Visual Studio .NET (2002) | Rainier | 7.0 | 13.00 | 1.0 | February 13, 2002 |
Visual Studio .NET 2003 | Everett | 7.1 | 13.10 | 1.1 | April 24, 2003 |
Visual Studio 2005 | Whidbey | 8.0 | 14.00 | 2.0, 3.0 | November 7, 2005 |
Visual Studio 2008 | Orcas | 9.0 | 15.00 | 2.0, 3.0, 3.5 | November 19, 2007 |
Visual Studio 2010 | Dev10/Rosario | 10.0 | 16.00 | 2.0 – 4.0 | April 12, 2010 |
Visual Studio 2012 | Dev11 | 11.0 | 17.00 | 2.0 – 4.5.2 | September 12, 2012 |
Visual Studio 2013 | Dev12 | 12.0 | 18.00 | 2.0 – 4.5.2 | October 17, 2013 |
Visual Studio 2015 | Dev14 | 14.0 | 19.00 | 2.0 – 4.6 | July 20, 2015 |
4.使用boost
设置Include目录:D:\work_files\boost_1_55_0
设置Lib目录:D:\work_files\boost_1_55_0\stage\lib
boost_wave-vc100-mt-gd-1_55.dll
这里mt代表multi thread
gd 代表 debug版本
然后就可以试试两个测试程序
一个测试头文件:
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}