Win7下VS2010使用boost
————
更新于2012年8月24日 星期五
http://blog.csdn.net/shunqiziranhao007/article/details/7905703
————
boost的官网下载boost文件。
http://www.boost.org/users/history/version_1_51_0.html
解压出来,有点大哦,420M。我的目录是,D:\boost_1_51_0 。
运行 D:\boost_1_51_0 目录下的 bootstrap.bat 。
将会产生一堆东西。
运行 D:\boost_1_51_0 目录下的 bjam.exe 。
等待一段时间,时间还真久。。。
在VS2010中设置 include目录和lib目录。
建立一个Win32 Console工程来设置和测试boost,然后在菜单 View,Property Manager,Debug | Win32,Microsoft.Cpp.Win32.user,VC++ Directories中。
Include Directories下添加 D:\boost_1_51_0 。
Library Directories下添加 D:\boost_1_51_0\stage\lib 。
确定就好了,以后创建工程后,都会包含该include目录和lib目录。
测试的时候遇到下面的问题:
1>CL : warning : STLPort debug versions are built with /D_STLP_DEBUG=1
1>d:\boost_1_51_0\boost\config\auto_link.hpp(209): fatal error C1189: #error : "Build options aren't compatible with pre-built libraries"
查资料得知是因为设置了STLport的原因。把STLport的include目录和lib目录删除掉就能正常build了。(我的做法,删除目录后的一个字母,这样设置就失效)
这个问题我还不能较好的解决,不知道怎么让STLport和boost共存。
测试程序如下:
/* 功能,Win7下VS2010使用boost。 日期,2012年8月24日 星期五 环境,Win7-32-vs2010 */ #include <iostream> #include <boost/regex.hpp> using namespace std; int main() { boost::regex reg("[a-z]+"); // regex_match 仅当整个输入数据被正则表达式成功匹配时才返回 true if (boost::regex_match( "232", reg)) { cout << "1找到了!" << endl; } if (boost::regex_match( "ab", reg)) { cout << "2找到了!" << endl; } if (boost::regex_match( "a2b", reg)) { cout << "3找到了!" << endl; } system("pause"); return 0; } /* 输出效果, 2找到了! Press any key to continue . . . */