1、 运行【VS目录】/Microsoft Visual Studio 8/VC/bin/vcvars32.bat (或者开始-->所有程序-->Microsoft Visual Studio 2005-->Visual Studio Tools-->Visual Studio 2005命令提示符),然后切换到boost1.39目录。
2、执行 [boost]/tools/jam/build_dist.bat
3、将 [boost]/tools/jam/stage/boost-jam-3.1.17-1-ntx86/bjam.exe 复制到 [boost]/bjam.exe
4、切换到[boost],运行bjam.exe "-sTOOLS=vc-8_0" install
5、在C:/boost下产生include和lib目录,及其近946M的文件。
6、将C:/Boost/include/boost-1_39 加入 VC2005 的 Include 路径
Tools | Options | Projects and Solutions | VC++ Directories
Show directories for: Include files
将 C:/Boost/lib 加入 VC2005 的 Lib 路径
Tools | Options | Projects and Solutions | VC++ Directories
Show directories for: Library files
7、测试代码
// 正则表达式测试:信用卡号码检测
#include <boost/regex.hpp>
#include <iostream>
bool validate_card_format(const std::string s)
{
static const boost::regex e("(//d{4}[- ]){3}//d{4}");
return regex_match(s, e);
}
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << (validate_card_format("1111-1111-1111-2222")?"PASS":"Error") ; // PASS
return 0;
}
// 计算两个日期相差的天数
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>
using namespace std;
using namespace boost::gregorian;
int _tmain(int argc, _TCHAR* argv[]){
date_duration dd = date(2000, 1, 1) - date(1900, 1, 1);
cout << "The twentieth century had " << dd.days() << " days" << endl; // 36524
dd = date(2100, 1, 1) - date(2000, 1, 1);
cout << "The twenty-first century will have " << dd.days() << " days" << endl; // 36525
return 0;
}
但是某些库还是需要单独编译一下才能使用,比如regex库
nmake -f vc8.make clean
------------------