如何安装boost库

详细教程可以参考: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
variantdebug,release 
linkshared,staticDetermines if Boost.Build creates shared or static libraries
threadingsingle,multiCause the produced binaries to be thread-safe. This requires proper support in the source code itself.
address-model32,64Explicitly 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 SYMBOLor 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-linkshared,staticDetermines 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/A4.0 N/A N/AApril 1995
Visual Studio 97Boston5.0 N/A N/AFebruary 1997
Visual Studio 6.0Aspen6.012.00 N/AJune 1998
Visual Studio .NET (2002)Rainier7.013.001.0February 13, 2002
Visual Studio .NET 2003Everett7.113.101.1April 24, 2003
Visual Studio 2005Whidbey8.014.002.0, 3.0November 7, 2005
Visual Studio 2008Orcas9.015.002.0, 3.0, 3.5November 19, 2007
Visual Studio 2010Dev10/Rosario10.016.002.0 – 4.0April 12, 2010
Visual Studio 2012Dev1111.017.002.0 – 4.5.2September 12, 2012
Visual Studio 2013Dev1212.018.002.0 – 4.5.2October 17, 2013
Visual Studio 2015Dev1414.019.002.0 – 4.6July 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;
    }
}



  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值