反反複複搞了幾次,終于好了!在此,特意寫了自認為最全的步驟,希望你們安裝順利!
下面介紹完整安裝boost庫的方法:
1、首先到boost官網去下載下傳最新的版本的boost庫:
http://www.boost.org/
http://www.boost.org/users/download/
(我下的是boost_1_67_0.zip)
2、解壓檔案,在指令提示符中打開到boost庫的根目錄下:
輕按兩下bootstrap.bat檔案,生成bjam.exe,執行以下指令:
bjam --toolset=msvc --build-type=complete stage
或者***直接輕按兩下bjam.exe***.(我選擇的是直接輕按兩下這個,然後運作了很久,五六個小時是有的,這可能跟自己的電腦有關,是以要耐心等待)

等待程式編譯完成,會在boost根目錄下生成bin.v2和stage兩個檔案夾,其中bin.v2下是生成的中間檔案,大小在2.7G左右,可以直接删除。stage生成一個***lib***檔案。
3、打開vs:
建立一個win32工程空項目,
視圖->屬性管理器->目前項目->Debug|X64->Microsoft.Cpp.X64.user輕按兩下
在彈出的屬性對話框中:
通用屬性->VC++目錄:“包含目錄”: boost的根目錄,例: D:\boost_1_67_0
“庫目錄”: stage下的連結庫目錄,例:D:\boost_1_67_0\stage\lib
通用屬性->連結器->正常:“附加庫目錄”:同上面的"庫目錄",例:D:\boost_1_67_0\stage\lib
4.環境配置好了,測試
測試代碼我是直接用了别人的代碼來測試
#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;
}
測試結果如下: