vs2010配备boost编程环境

来源:互联网 发布:五轴加工中心编程软件 编辑:程序博客网 时间:2024/04/30 14:57

vs2010配备boost编程环境

vs2010配置boost编程环境

第一步:下载boost,我下载的方法是从http://www.boost.org/上找最新的下载。名字叫boost_1_53_0。

第二步:在D盘(最新的boost_1_53_0编译之后大小为5G多)创建一个目录boost,拷贝进去并解压到当前文件夹。(注,这里我没有创建boost目录,直接解压的)

第三步:开始->程序->MicrosoftVisual Studio 2010->Visual Studio Tools->Visual Studio 命令提示(2010),打开一个控制台。

第四步:cd d:\boost\boost_1_53_0

第五步:bootstrap.bat

第六步:(1)b2--toolset=msvc-10.0 --build-type=complete stage或者(2)bjam.exe--toolset=msvc-10.0 --build-type=complete。等待执行完成。

注:我在这里第五步之后会生成了bjam.exe和b2.exe.这里我执行(1)成功,执行(2)失败

测试:

第一步:创建一个工程,附加包含目录为:d:\boost\boost_1_53_0;附加库目录为:d:\boost\boost_1_53_0\stage\lib

注:在2010环境下这步,在项目-->右键属性-->VC++ Directories 中去填写对应路径

这两步我的配置的时候是:(1)D:\boost_1_53_0 (2)D:\boost_1_53_0\stage\lib

第二步:编写代码测试。

注:如果编写的测试代码出现类似错误”无法打开包括文件:“boost/regex.hpp”: No such file or directory” 说明附件包含目录出现错误,这时要纠正包含目录。

如果在下还有incude目录,我们只需包含includes目录就加载了相关头文件,如果没有,如上加载总目录,让编译器自己找。

附加:据说在第六步的时候,如果将执行指令里面的“stage”改成”install”,则会生成include指令。

附加测试代码:

C++ Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

#include<iostream>
#include <boost/regex.hpp>
using namespace std;

int main()
{
// 3 digits, a word, any character, 2 digits or "N/A",
// a space, then the first word again
boost::regex reg("\\d{3}([a-zA-Z]+).(\\d{2}|N/A)\\s\\1");

std::string correct="123Hello N/A Hello";
std::string incorrect="123Hello 12 hello";

assert(boost::regex_match(correct,reg)==true);
assert(boost::regex_match(incorrect,reg)==false);
cout<<"Hello Boost !"<<endl;
}

如果输出结果为:


则表明boost库在vs2010下配置成功。

0 0
原创粉丝点击