標籤:pause 管理器 art null time _each out cout space
由於boost都是使用模板的技術,所以全部代碼都是寫在一個.hpp標頭檔裡。這樣boost中的大部分內容是不須要編譯產生對應的連結庫,僅僅須要設定以下的包括檔案夾(或者設定一下環境變數),在源檔案裡包括對應的標頭檔就能夠使用了。
少部分庫須要產生連結庫來使用。
以下介紹完整安裝boost庫的方法:
1、首先到boost官網去下載最新的版本號碼的boost庫:
http://www.boost.org/
2、解壓檔案。在命令提示字元中開啟到boost庫的根資料夾下:
雙擊bootstrap.bat檔案,產生bjam.exe,運行下面命令:
bjam --toolset=msvc --build-type=complete stage
或者直接雙擊bjam.exe.
等待程式編譯完畢,大約要兩個小時左右。會在boost根資料夾下產生bin.v2和stage兩個檔案夾。當中bin.v2下是產生的中間檔案,大小在2.7G左右,能夠直接刪除。stage下才是產生的dll和lib檔案。
3、開啟vs:
視圖->屬性管理員->當前項目->Debug|Win32->Microsoft.Cpp.Win32.user雙擊
在彈出的屬性對話方塊中:
通用屬性->VC++檔案夾:"包括檔案夾": boost的根資料夾。例: D:\Visual Stdio 2013\lipeng\boost\boost_1_58_0
"庫檔案夾": stage下的連結庫檔案夾。例:D:\Visual Stdio 2013\lipeng\boost\boost_1_58_0\stage\lib
通用屬性->連結器->常規:"附加庫檔案夾":同上面的"庫檔案夾",例:D:\Visual Stdio 2013\lipeng\boost\boost_1_58_0\stage\lib
至此環境就配置好了。以下測試一下:
<span style="font-size:14px;"><pre name="code" class="cpp"><span style="font-family:Courier New;">#include <cstdlib>#include <iostream>#include <vector>#include <iterator>#include <algorithm>#include <boost/timer.hpp>#include <boost/progress.hpp>#include <libs/date_time/src/gregorian/greg_names.hpp>#include <libs/date_time/src/gregorian/date_generators.cpp>#include <libs/date_time/src/gregorian/greg_month.cpp>#include <libs/date_time/src/gregorian/gregorian_types.cpp>#include <boost/date_time/posix_time/posix_time.hpp>using namespace boost;int main(){boost::timer t;boost::progress_display pd(100);for (int i = 0; i < 100; ++i) //進度條{++pd;}boost::gregorian::date dt(2009, 12, 8); //date_time 庫assert(dt.year() == 2009);assert(dt.day() == 8);boost::gregorian::date::ymd_type ymd = dt.year_month_day();std::cout<<"\n"<<ymd.year<<"/"<<ymd.month<<"/"<<ymd.day<<" the day is "<<dt.day_of_year() <<" days of this year"<< std::endl;std::cout << boost::gregorian::to_iso_extended_string(dt) << std::endl; //轉換為其它格式std::cout << boost::gregorian::to_iso_string(dt) << std::endl;std::cout << boost::gregorian::to_simple_string(dt) << std::endl<<std::endl;//對數組排序操作std::vector<int> test_vc(100);std::vector<int>::iterator beg_it = test_vc.begin();std::vector<int>::iterator end_it = test_vc.end();std::srand(std::time(NULL));std::for_each(beg_it, end_it, [](int& n){n = rand(); });std::copy(beg_it, end_it, std::ostream_iterator<int>(std::cout, " "));std::cout << std::endl << std::endl;std::sort(beg_it, end_it, std::greater<int>());std::copy(beg_it, end_it, std::ostream_iterator<int>(std::cout, " "));std::cout << std::endl<<std::endl;boost::posix_time::ptime pt(boost::gregorian::date(2005, 2, 6));std::cout << t.elapsed() << "s" << std::endl; //程式執行時間system("pause");return 0;}</span></span>
程式正確執行:
作者: http://blog.csdn.net/lp310018931
windows下boost庫的基本用法