反反复复搞了几次,终于好了!在此,特意写了自认为最全的步骤,希望你们安装顺利!
下面介绍完整安装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;
}
测试结果如下: