VS2005(VC8) 使用 Boost
来源:互联网 发布:2013年最火的网络歌曲 编辑:程序博客网 时间:2024/04/30 18:06
Chui-Wen Chiu
http://chuiwenchiu.spaces.live.com
2006.12.12
測試環境:
[1] Widnows XP Professional
[2] Visual Studio 2005 Team Studio(VC8.0)
[3] WinCvs 1.3
1. 下載 Boost
2. 組態設定
3. 建置與安裝(* [boost] 表示 boost 的根目錄)
4. 測試
參考資料:
[1] http://www.boost.org/more/getting_started.html
[2] http://www.programmer-club.com/pc2020v5/forum/ShowSameTitleN.asp?URL=N&board_pc2020=c&index=8&id=33560&mode=quarter&type_pc2020=sametitleLevel-2
http://chuiwenchiu.spaces.live.com
2006.12.12
測試環境:
[1] Widnows XP Professional
[2] Visual Studio 2005 Team Studio(VC8.0)
[3] WinCvs 1.3
1. 下載 Boost
- 透過 CVS 下載最新版
cvs -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost login
[詢問密碼時,直接輸入 Enter 略過]
cvs -z3 -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost checkout boost
cvs -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost logout
2. 組態設定
- 執行 C:/Program Files/Microsoft Visual Studio 8/VC/bin/vcvars32.bat
3. 建置與安裝(* [boost] 表示 boost 的根目錄)
- 執行 [boost]/tools/jam/build_dist.bat
- 將 [boost]/tools/jam/src/boost-jam-3.1.14-1-ntx86/bjam.exe 複製到 [boost]/bjam.exe
- 切換到 [boost]/ 執行 bjam "-sTOOLS=vc-8_0" install
- 漫長的等待~~~~~~~~ 相關 header 與 lib 產生在 C:/Boost
- 修改 C:/Boost/include/boost-1_35/boost/config/suffix.hpp 內容
# define BOOST_LIB_TOOLSET "vc80"
成如下
# define BOOST_LIB_TOOLSET "vc"
(或是將 c:/Boost/Lib/ 下的所有 *.lib 的 -vc- 取代為 -vc80- (如:bgl-viz-vc.lib -> bgl-viz-vc80.lib, boost_date_time-vc-1_35.dll -> boost_date_time-vc80-1_35.dll)否則程式在連結時會發生找不到 lib 的錯誤)
- 將 C:/Boost/include/boost-1_35 加入 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
4. 測試
// 正規表示法測試:信用卡號檢測
#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 <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;
}
#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;
}
參考資料:
[1] http://www.boost.org/more/getting_started.html
[2] http://www.programmer-club.com/pc2020v5/forum/ShowSameTitleN.asp?URL=N&board_pc2020=c&index=8&id=33560&mode=quarter&type_pc2020=sametitleLevel-2
- VS2005(VC8) 使用 Boost
- VS2005(VC8) 使用 Boost
- VS2005(VC8)编译、配置Boost.regex
- (VC8)配置boost库使用环境
- VS2005 下使用BOOST
- 使用vs2005(vc8)编译log4cpp-0.3.5rc3
- 使用vs2005(vc8)编译log4cpp-0.3.5rc3
- vs2005+vc8+ado
- VS2005使用boost库教程
- __invalid_parameter_noinfo vs2005 vc8 问题解决办法
- VS2005(VC8)编译Xalan-C_1_10_0
- __invalid_parameter_noinfo vs2005 vc8 问题解决办法
- Install Boost Library for VC8
- vs2005下 使用boost::regex 和 filesystem
- VS2005 使用Boost库的编译步骤
- boost在VS2005下的使用
- boost编译,vc8和vc9的问题
- gSoap2.7.9+vc8使用总结
- div+css实现圆角边框
- T-SQL常用关键字和语法
- 在事件中引用aspx页面repeater控件所包含控件的数据
- 在上下九拍到的(CS03的兄弟姐妹们注意了)
- 关于linux下的mkdir函数
- VS2005(VC8) 使用 Boost
- equals重写的例子
- 用devcpp配置控制台编译的gcc、g++环境
- 基于ARM9的视频采集传输系统
- 使用OTL调用Oracle的存储函数
- 使用devcpp(mingw)编译产生JNI中的dll
- VHDL 根本就不是语言
- VS2005(VC8)编译、配置Boost.regex
- 做好事了