windows下boost庫的基本使用方法

來源:互聯網
上載者:User

標籤:boost   boost date   stl   vs boost   

1、首先到boost官網去下載最新的版本的boost庫:

http://www.boost.org/


2、解壓檔案,在命令提示字元中開啟到boost庫的根目錄下,執行以下命令:

bjam --toolset=msvc --build-type=complete stage

等待程式編譯完成,大約要兩個小時左右,會在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


至此環境就配置好了,下面測試一下:

#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>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);std::cout <<std::endl<< "the day is "<<dt.day_of_year() <<" day of this year"<< 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));for (; beg_it != end_it; ++beg_it){*beg_it = rand();}beg_it = test_vc.begin();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;std::cout << t.elapsed() << "s" << std::endl;system("pause");return 0;}


程式正確運行:



作者: http://blog.csdn.net/lp310018931

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

windows下boost庫的基本使用方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.