<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} pre {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:宋体;} tt {font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:宋体; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->
Boost installation guide.
准备安装一个 boost 开发运行环境, google 很多资料,发现都不合用,最后还是官方文档帮助了哦。呵呵。
Step1 下载,解压
tar --bzip2 -xf /path/to/
boost_1_44_0
.tar.bz2
Step2 测试包是否完好
例子程序:
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
编译方法:
c++ -I path/to/
boost_1_44_0
example.cpp -o example
运行:
echo 1 2 3 | ./example
Step3 安装 Boost Library
$ cd path/to/ boost_1_44_0
$ ./bootstrap.sh --help
./bootstrap.sh --prefix=
path
/to
/installation
/prefix
默认路径是 /usr/local
./bjam install
Step4 测试类库是否可用
例子程序:
#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;
}
}
编译:
$ c++ -I path/to/
boost_1_44_0
example.cpp -o example /
~/boost/stage/lib/libboost_regex-gcc34-mt-d-1_36.a
类库路径建议使用绝对路径
运行:
./example
总结:
如何参考文档都是虚的,最好还是参考官方的指导文档。