首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

VS2008上Boost库的安装编译上载boost库

2014-07-11 
VS2008下Boost库的安装编译下载boost库下载boost库 (最好去官网下,一般有SGI(GCC+用的较多)和BOOST之分,VS

VS2008下Boost库的安装编译下载boost库
下载boost库 (最好去官网下,一般有SGI(GCC+用的较多)和BOOST之分,VS下用BOOST)
http://dl2.csdn.net/fd.php?i=21242861316189&s=39836e47ecfaa50a8b9208b6ecd5c798
下载boost_1_34_1(最新版本执行方法一样,改下名字即可)压缩文件,解压缩 到d:\boost_1_34_1\(可以任何位置,你觉得合适就可以)目录下


1.编译bjam
从开始->程序->Microsoft Visual Studio 2008->Visual Studio Tools->Visual Studio 2008 命令提示(一定要从这进),命令提示cd到d:\boost_1_34_1\tools\jam\src下执行build.bat,会在d: \boost_1_34_1\tools\jam\src\bin.ntx86\产生 bjam.exe,把bjam.exe复制到 d:\boost_1_34_1\下。
2.编译boost
命令提示cd到d:\boost_1_34_1\下執行
bjam --without-python --toolset=msvc-9.0 --prefix=d:\boost install
參數說明
--without-python 表示不使用 python
--toolset : 所使用compiler,Visual Studio 2008為msvc-9.0
--prefix:指定编译后library的安裝目录
这一步要花很长时间(大约20分钟),看你的电脑速度
3.设定vs2008环境
启动vs2008->工具->选项-> 项目和解决方案 -> VC++目录
下拉 库文件 加上d:\boost\lib
下拉 包含文件 加上d:\boost\include\boost-1_34_1
这样基本已经完成了!


注意:如果发现libboost_regex-vc80-mt-gd-1_34_1.lib之类文件 提示错误时,是找不到该文件!
就到D:\boost\lib  把对应的文件libboost_regex-vc90-mt-gd-1_34_1.lib改为 libboost_regex-vc80-mt-gd-1_34_1.lib(可以用记事本或者写字板打开,然后保存)就可以一般是80和90的差别 (2005是80,2008是90)

4.测试安装是否成功
#include <iostream>
#include <string>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string_regex.hpp>
using namespace std;
using namespace boost;
int main() {
    string s = "    Hello boost!! ";
    trim(s);
    cout << s << endl;
    getchar();
       std::string regstr = "a+";
      boost::regex expression(regstr);
      std::string testString = "aaa";
      // 匹配至少一个a
      if( boost::regex_match(testString, expression) )
      {
          std::cout<< "Match" << std::endl;
      }
      else
      {
          std::cout<< "Not Match" << std::endl;
      }
}

输出:
Hello boost!

Match
表示成功

热点排行