a这个可行
http://jingyan.baidu.com/article/00a07f3843a33e82d028dcbf.html
最近打算学习一下Boost库,这里记录一下Boost库的安装的方法。
方法/步骤
-
下载:
先到Boost官方网上下载源代码。
-
编译VS2008版本的Boost库:
首先,编译bjam,在命令行下,运行bootstrap.bat -vc9,然后,编译库。
编译动态库:bjam stage --toolset=msvc-9.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\vc9" link=static runtime-link=shared threading=multi debug release
编译静态库:bjam stage --toolset=msvc-9.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\vc9" link=static runtime-link=static threading=multi debug release
编译用了15分钟左右,产生了303MB左右的文件
-
VS2008 Boost库配置:
Tools -> Options -> Projects and Solutions -> VC++ Directories 在Library files中,增加D:\Boost\bin\vc9\lib在Include files中,增加D:\Boost\其中,Library的目录就是前面编译产生的那些库文件保存到的位置其中,Include的目录随着Boost的不同版本会不同,现在1.47版本只要指定为D:\Boost即使用SVN下载Boost的文件夹就可以了。
-
VS2008 Boost库测试:
#include "stdafx.h"
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>
using namespace std;
using namespace boost;
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"请输入您的生日,格式\"YYYY-MM-DD\":";
string strBirthday;
cin>>strBirthday;
try
{
gregorian::date birthday( gregorian::from_simple_string(strBirthday) );
gregorian::date today( gregorian::day_clock::local_day() );
gregorian::days days_alive = today - birthday;
if( days_alive < gregorian::days(0) )
{
cout<<"哇,还没出生就能用电脑了,真厉害"<<endl;
}
else
{
cout<<"您在这个世界上出现了:"<< days_alive.days()<< "天了" << endl;
}
}
catch( gregorian::bad_year& e )
{
cerr<< e.what() << endl;
}
catch( gregorian::bad_day_of_month& e )
{
cerr<< e.what() << endl;
}
catch( gregorian::bad_day_of_year& e )
{
cerr<< e.what() << endl;
}
catch(...)
{
cerr<<"Error!"<<endl;
}
system( "pause" );
return 0;
}