Windows环境下使用Boost

Windows环境下使用Boost - chuncn - 博客园

Windows环境下使用Boost

一、 下载boost

1、boostpro

http://www.boostpro.com/download/

2、boost.org(本文下载方式)

http://www.boost.org/users/download/

http://sourceforge.net/projects/boost/files/boost/1.51.0/

boost_1_51_0.zip 下载并解压到C盘根文件夹

二、编译boost

1、生成生命行程序

执行bootstrap.bat

2、编译

执行b2.exe,完成后显示:

The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
    C:/boost_1_51_0
The following directory should be added to linker library paths:
    C:\boost_1_51_0\stage\lib

三、使用boost

1、创建一个win32 console

2、引用bootst

C/C++ -> Additional Include Directories: C:\boost_1_51_0
Linker-> Additional Library Directories: C:\boost_1_51_0\stage\lib
Linker->Input->Additional Dependencies :libboost_signals-vc110-mt-gd-1_51.lib;libboost_regex-vc110-mt-gd-1_51.lib;

3、Code如下:

?
#include "stdafx.h"
#include <boost/regex.hpp>
#include <boost/signals.hpp>
#include <boost/lambda/lambda.hpp>
 
#include <iostream>
#include <cassert>
  
struct print_sum {
   void operator()( int x, int y) const { std::cout << x+y << std::endl; }
};
  
struct print_product {
  
   void operator()( int x, int y) const { std::cout << x*y << std::endl; }
  
};
 
int _tmain( int argc, _TCHAR* argv[])
{
     boost::signal2< void , int , int , boost::last_value< void >, std::string> sig;
     sig.connect(print_sum());
     sig.connect(print_product());
     sig(3, 5);
     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;    
     }
     return 0;
}

 

 示例程序在vs2012下通过,输出:

8
15

posted on 2013-01-10 16:31  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2013/01/10/2855044.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值