Boost官方网站: http://www.boost.org/doc/libs/1_47_0/more/getting_started/windows.html
在线傻瓜安装 : http://www.boostpro.com/download/ ,这个好像不能用了,用我的百度盘吧:http://pan.baidu.com/s/1eQIcSJg
一些同学反映我写错了,的确这里比较简单的描述(非常抱歉),强烈建议先看完:Visual C++ 2010 加载DLL动态链接库 http://blog.csdn.net/calmreason/article/details/6989390
VS中使用boost库:
如果你只是用那些不需要编译就可以使用的部分,比如lexical,那么你只需要让你的编译器找到对应的Boost的源代码即可(即在项目中添加boost根目录,或者将boost的根目录直接拷贝到 C:\Program Files\Microsoft Visual Studio 10.0\VC\include中)
如果你使用库需要编译,比如regex库,那么你需要添加源代码,并同时添加编译好的lib,dll文件到你的项目中。lib和dll文件的生成,可以使用自动安装工具安装(好像不能用了),也可以自行编译(貌似比较麻烦哈。我还没搞过)
添加头文件的两种方法 :
此时编译如下源文件:
#include<iostream> #include <boost/regex.hpp> using namespace std; int main() { cout<<"Hello Boost !"<<endl; }
出现如下编译错误:
LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc100-mt-gd-1_51.lib'
2 添加lib和dll文件到工作目录 :
此时运行上面的源程序,结果如下:
若运行如下程序:
#include<iostream> #include <boost/regex.hpp> using namespace std; int main() { // 3 digits, a word, any character, 2 digits or "N/A", // a space, then the first word again boost::regex reg("\\d{3}([a-zA-Z]+).(\\d{2}|N/A)\\s\\1"); std::string correct="123Hello N/A Hello"; std::string incorrect="123Hello 12 hello"; assert(boost::regex_match(correct,reg)==true); assert(boost::regex_match(incorrect,reg)==false); cout<<"Hello Boost !"<<endl; }
结果如下
完毕,所以使用专门的boost安装软件,只需要将两个目录加入到编译器中就可以使用boost库了,多方便啊!