Chinaunix首页 | 论坛 | 博客
  • 博客访问: 86297
  • 博文数量: 18
  • 博客积分: 510
  • 博客等级: 中士
  • 技术积分: 300
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-27 20:37
文章分类

全部博文(18)

文章存档

2011年(18)

分类: LINUX

2011-05-04 09:42:58

操作系统:centos-5.6

如果要使用boost的graph库,必须先安装icu库(icu4c-4_0-src.gz)

1、解压 tar zxvf boost_1_46_1.tar.gz

(我的当前目录为/root)

2、编译和安装,先切换到目录boost_1_46_1

  1. ./bootstrap.sh
  2. ./bjam
  3. ./bjam install

3、设置环境变量:

  1. BOOST_ROOT=/root/boost_1_46_1
  2. BOOST_INCLUDE=/usr/local/include/boost
  3. BOOST_LIB=/usr/local/lib
  4. export BOOST_ROOT BOOST_INCLUDE BOOST_LIB

4、测试:

//regex.cpp

  1. #include <boost/regex.hpp>
  2. #include <iostream>
  3. #include <string>

  4. int main()
  5. {
  6.     std::string line;
  7.     boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );

  8.     while (std::cin)
  9.     {
  10.         std::getline(std::cin, line);
  11.         boost::smatch matches;
  12.         if (boost::regex_match(line, matches, pat))
  13.             std::cout << matches[2] << std::endl;
  14.     }
  15. }

编译:g++ -g -I$BOOST_INCLUDE -L$BOOST_LIB -o regex regex.cpp -lboost_regex

执行:./regex

5、如果执行./regex时报错

  1. ./regex: error while loading shared libraries: libboost_regex.so.1.46.1: cannot open shared object file: No such file or directory

编辑/etc/ld.so.conf

加入库路径 /usr/local/lib

阅读(1695) | 评论(0) | 转发(0) |
0

上一篇:DDD安装

下一篇:linux常用技巧

给主人留下些什么吧!~~