官网下载boost1.60.0-msvc14-32.exe
安装:
预先安装msvc14
直接安装
安装结束:
双击bootstrap.bat
在切换到解压安装目录
bjam -j4 --debug-symbols=on --build-type=complete toolset=msvc-14.0 threading=multi runtime-link=shared address-model=32
对于boost 来说,很多库都是.hpp格式,仅包含头文件即可!!不需要静态库!而静态库在./stage/lib/.不是./lib32-msvc-14.0/文件下, 也不是/libs/
上一步编译结束后,会有如上提示。
定义包含路径D:\boost_1_60_0;
定义是否包含预定义头文件In Configuration Properties > C/C++ > Precompiled Headers, change Use Precompiled Header (/Yu) to Not Using Precompiled Headers
入门可以参考文件下的index.html 说明
使用vs2015 跑一个小例子:
#include <boost/version.hpp>
#include <boost/config.hpp>
#include <iostream>
using namespace std;
int main()
{
cout << BOOST_VERSION << endl;
cout << BOOST_LIB_VERSION << endl;
cout << BOOST_PLATFORM << endl;
cout << BOOST_COMPILER << endl;
cout << BOOST_STDLIB << endl;
}
2
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " ");
}
3
#include <boost/lexical_cast.hpp>
//这里目录明明是lexical_caset_old.hpp ??
#include <iostream>
using namespace std;
int main()
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.0123456789");
string s0 = lexical_cast<string>(a);
string s1 = lexical_cast<string>(b);
cout << "number: " << a << " " << b << endl;
cout << "string: " << s0 << " " << s1 << endl;
int c = 0;
try {
c = lexical_cast<int>("abcd");
}
catch (boost::bad_lexical_cast& e) {
cout << e.what() << endl;
}
return 0;
}
当需要库lib的时候,可能还需要指定dll 拷贝到./windows/sysWOW64