Eclipse - Eclipse & MinGW & Boost 配置

Eclipse & MinGW & Boost 配置


版权所有, 禁止转载, 如有需要, 请站内联系

本文地址: http://blog.csdn.net/caroline_wendy/article/details/17282187


Boost作为C++的一个最关键的库, 是每一个C++编程人员需要使用的, 本文讲解如何在Eclipse+MinGW下配置boost库;


1. Eclipse安装CDT插件和MinGW

可以按照如下链接完美配置; 地址: http://blog.csdn.net/caroline_wendy/article/details/17039847;


2. 下载boost

下载boost最新版本MinGW的文件下, 并解压, 最新版本: http://www.boost.org/users/history/version_1_55_0.html

windows环境比linux难配置, 所以选择讲解windows版本;



3. 编译boost

由于boost有些库, 如regex(正则), 需要手动编译, 不能直接使用;

点击, 根目录下的"bootstrap.bat"文件, 会生成"bjam.exe", 文件, 最终编译出的库会生成在stage文件夹中;


如果直接双击bjam是生成的VS版本的库文件;

如果生成MinGW的GCC版本的库文件, 需要输入命令"bjam.exe  --build-type=complete toolset=gcc stage"

如图, 已经编译结束:



4. 项目配置boost库

添加系统环境变量Path, 使系统可以找到dll, "XXX\boost\stage\lib", XXX为具体路径; 注销或重启电脑;

主要包含两个位置, 一个是include目录, 一个lib目录, 具体位置, 如添加regex库, 如图:




5.测试代码:

#include <boost/regex.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using namespace boost;

int main()
{
	string pattern("[^c]ei");
	pattern = "[[:alpha:]]*" + pattern + "[[:alpha:]]*";
	regex r(pattern);
	smatch results;
	string test_str = "receipt freind theif receive";
	if(regex_search(test_str, results, r))
		cout << results.str() << std::endl;
}


  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ElminsterAumar

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值