搭建vs2010 boost开发环境

时间:2023-03-10 06:56:47
搭建vs2010 boost开发环境

一、编译boost库

第一步:下载boost库,下载地址http://sourceforge.net/projects/boost/files/boost/1.55.0/

第二部:解压boost库,例如解压到F:\Third-party libs\boost\boost_1_55_0

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

第四部:cd F:\Third-party libs\boost\boost_1_55_0

第五部:bootstrap.bat

第六步:bjam.exe --toolset=msvc-10.0 --build-type=complete

二、测试环境

第一步:创建一个工程,附加包含目录为:F:\Third-party libs\boost\boost_1_55_0;附加库目录为:F:\Third-party libs\boost\boost_1_55_0\stage\lib

第二部:编写代码测试

#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;
}

第三部:编译运行,如果输出结果为:

搭建vs2010 boost开发环境

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