在Windows下Boost库编译方法与测试
2015-12-11 23:59
357 查看
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;
}
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;
}
相关文章推荐
- Nginx + Tomcat + Memcached 集群搭建
- HTML5 HTTP协议推送 java版
- swift分享到微信
- Expression Add Operators
- hashCode()方法与equals()方法
- Android开发-mac上使用三星S3做真机调试
- 6级核心词汇
- 3GPP 36211-c70-8(内容不太懂)
- TIME_WAIT、 CLOSE_WAIT
- 让你的网站和移动端支持Emoji
- Linux ->> Apt-get命令安装软件
- Windows 10开发基础——指针事件和操作事件(一)
- 2015-12-06 第七天课程笔记
- 函数指针
- Android 之自定义view实现水波纹效果
- 深入理解Java Proxy机制
- mac chromedriver error
- 常用dos命令(五)--DEL和ERASE命令
- 【Linux运维入门】Linux环境安装配置JBoss
- 实时控制软件设计第二次作业