1. Get & Build & Install Boost
download boost from http://www.boost.org/
进入boost目录,使用命令:
./bootstrap.sh --prefix=path/to/installation
./b2 install
如此之后:
leave Boost binaries in the lib/ subdirectory of your installation prefix. You will also find a copy of the Boost headers in theinclude/ subdirectory of the installation prefix, so you can henceforth use that directory as an #include path in place of the Boost root directory.
2. Use Boost
1) Header-Only Libraries
Most Boost libraries are header-only: they consist entirely of header files containing templates and inline functions, and require no separately-compiled library binaries or special treatment when linking.
比如下面这个例子,使用的就是header-only的library.
#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_47_0 example.cpp -o example
then:
echo 1 2 3 | ./example
2) Separately-Compiled Binary
#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++ -I /home/bin.jinb/usr/local/boost/include/ test.cc -o test \
-L /home/bin.jinb/usr/local/boost/lib/ -lboost_regex
或者:
g++ -I /home/bin.jinb/usr/local/boost/include/ test.cc -o test \
/home/bin.jinb/usr/local/boost/lib/libboost_regex.a
分享到:
相关推荐
boost C++Boost boost入门 boost简介
Boost社区的发起人Dawes本人就是C++标准委员会的成员之一。大部分boost库功能的使用只需包括相应头文件即可,少数(如正则表达式库,文件系统库等)需要链接库。里面有许多具有工业强度的库,如graph库。STL集中在...
C++ BOOST 正则表达式 使用教程 兼容 PERL 正则表达式
c++ 用的boost库,该库提供了强大的函数,很多可以作为基础的函数来使用。
Boost社区建立的初衷之一就是为C++的标准化工作提供可供参考的实现,Boost社区的发起人Dawes本人就是C++标准委员会的成员之一。在Boost库的开发中,Boost社区也在这个方向上取得了丰硕的成果。在送审的C++标准库TR1...
c++boost库最新版本
C++ Boost库学习记录-安装,详述了boost库德安装使用过程,方便快捷
boost库下载,c++库,方便,高效,比c++标准程序库好用!
使用c++实现boost::any类 any类可以存放任意类型数据,如: void test_any() { any any_a1(123); int a2 = any_cast(any_a1); int* p_a2 = any_cast(&any_a1); std::cout *p_a2="*p_a2; any any_b1(12.35); ...
标准C C++ STL参考手册中英文——三个文档 boost基础,boost开发——两个文档 共五个文档
C++ Boost库1.70.0最新版本 免费资源以便于不能访问下载链接的用户进行下载使用
c++ boost-1.58 开源动态库文件, 使用 vs2013
boost中文手册C++ boost库让我们更快、更好地使用C++进行大型系统或者服务器开发工作,提高工作效率,很值得一看!
c++和boost的历史,boost库功能和原理及应用介绍
该c++ web server基于boost.asio库编写,同时支持http和https协议。该工程基于vs2015编译通过,相关配置和说明见readme.txt
C++远程方法调用框架 RMI for C++ 附加boost库
http协议是互联网上应用最为广泛的一种网络协议,他在接口中扮演着重要的角色,Post/Get请求,想必大家都有所耳闻,我们一起利用Boost::Asio库来实现Post/Get请求的发送。 VS2013 文章地址:...
c++ boost库的编译,PDF扫描版,讲述怎样编译boost,主要适用于window visual studio
最近开发中用到大量BOOST库的东西,现在把我开发中总结的boost使用方法分享一下,里面包括智能指针、boost定时器、boostthread和io_service等的用法和说明,还有一本Beyond the C++ Standard Library: An ...