1. 安装:
按照官网上做法http://www.boost.org/doc/libs/1_54_0/more/getting_started/unix-variants.html
如果没有服务器的root权限,就要安装在自己的目录下,指明prefix
./bootstrap.sh --prefix=path/to/installation/prefix
然后,./b2 install
编译成功之后,就会在指定的目录下生成两个文件,include, lib,一个放头文件,一个放链接库
设安装目录是 /XX/XXX/boost
2.
编译
#include <iostream>
#include <string>
#include <boost/regex.hpp>
int main() {
std::string s = "who,lives:in-a,pineapple under the sea?";
boost::regex re(",|:|-|\\s+");
boost::sregex_token_iterator
p(s.begin( ), s.end( ), re, -1);
boost::sregex_token_iterator end;
while (p != end)
std::cout << *p++ << '\n';
}
g++ tt.cpp -I/XX/XXX/boost -lboost_regex -o re
-I(这是大写的i) -l(这是小写的L)
-l指明了boost的安装目录
-l指明了用到的链接库