操作系统: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
- ./bootstrap.sh
- ./bjam
- ./bjam install
3、设置环境变量:
- BOOST_ROOT=/root/boost_1_46_1
- BOOST_INCLUDE=/usr/local/include/boost
- BOOST_LIB=/usr/local/lib
- export BOOST_ROOT BOOST_INCLUDE BOOST_LIB
4、测试:
//regex.cpp
- #include <boost/regex.hpp>
- #include <iostream>
- #include <string>
- int main()
- {
- std::string line;
- boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
- while (std::cin)
- {
- std::getline(std::cin, line);
- boost::smatch matches;
- if (boost::regex_match(line, matches, pat))
- std::cout << matches[2] << std::endl;
- }
- }
编译:g++ -g -I$BOOST_INCLUDE -L$BOOST_LIB -o regex regex.cpp -lboost_regex
执行:./regex
5、如果执行./regex时报错
- ./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
阅读(1722) | 评论(0) | 转发(0) |