C++之Boost使用
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
C++之Boost使用相关推荐
- Linux下安装 boost 库
1. 先去官网下载压缩包: https://www.boost.org/ 2. 解压后cd 进入根目录,然后执行: ./bootstrap.sh 3. 安装(时间会很长): ./b2 install ...
- Mysql依赖库Boost的源码安装,linux下boost库的安装
boost'准标准库'安装过程. 安装的是boost_1_60_0. (1)首先去下载最新的boost代码包,网址www.boost.org. (2)进入到自己的目录,解压: bzip2 -d boo ...
- 函数指针amp;绑定: boost::functoin/std::function/bind
see link: https://isocpp.org/wiki/faq/pointers-to-members function vs template: http://stackoverflow ...
- Boost 1.53.0 发布,可移植的C++标准库
Boost 1.53.0 发布了,包含了 5 个新的库,修复了一些安全漏洞以及 Boost.Locale 组件的 bug . 新增的 5 个库包括: Boost.Atomic Boost.Corout ...
- cmake开发环境 linux qt_一步步搭建CMake+QT+VTK+BOOST开发环境
开发环境: 1.可以迅速处理大量并发网络数据包,ASIO库和winpcap 4.1.3库; 2.处理与显示点云模型数据,使用VTK 8.2.0库; 3.项目使用CMake+VC2017编译,GUI使用 ...
- boost::asio使用UDP协议通信源码实现
说明:以下源码来自参考文献[1], 比原文更丰富, 更有指导意义, 方便日后参考. udp servr端源码 //g++ -g udp_server.cpp -o udp_server -lboost ...
- 使用boost解析域名服务
下面的源码给出了使用boost::asio进行域名解析的方法. //g++ -g resolver_demo.cpp -o resolver_demo -lboost_system -lpthread ...
- boost::asio异步模式的C/S客户端源码实现
异步模式的服务器源码 //g++ -g async_tcp_server.cpp -o async_tcp_server -lboost_system //#include <iostream& ...
- boost::asio中的C/S同步实例源码
近来狂热地研究boost的开发技术,现将读书笔记整理如下: 需要说明的是, 本博该专题下面关于boost的源码是采用boost1.55版本, 运行在Ubuntu 14.04 64bit下面, 使用ap ...
- 【Boost】noncopyable:不可拷贝
[CSDN]:boost::noncopyable解析 [Effective C++]:条款06_若不想使用编译器自动生成地函数,就该明确拒绝 1.example boost::noncopyable ...
最新文章
- Django的下载与基本命令
- cocos2d-x之读取json文件
- 风口摔死的飞猪:致那些“消失”的互联网创业项目
- python实例 列表
- 高级会计师资格考试成绩合格证在全国范围内几年有效
- Oracle学习:条件表达式及分组函数
- linux挂载硬盘 只读,mount: /dev/vdb 写保护,将以只读方式挂载
- 高性能mysql 聚簇索引,高性能MySQL笔记-第5章Indexing for High Performance-005聚集索引...
- C++子类对象隐藏了父类的同名成员函数(隐藏篇)
- [python]---从java到python(03)---爬虫
- java 正则表达式 组合_java基础:5.1 面向对象、类的关联 聚合 组合、正则表达式...
- 物联网通信协议——比较-MQTT、 DDS、 AMQP、XMPP、 JMS、 REST、 CoAP
- 安装Oracle11g-client
- 【Unity Shaders】Mobile Shader Adjustment —— 为手机定制Shader
- 【前端】【cornerstone】如何使用segment分割相关组件
- 火狐中jq的attr出现的bug问题用prop代替
- 输入字符串按照单词逆序输出
- C++笔记(6)友元
- rpath失效是怎么回事
- windows 10 Office 2016 安装
热门文章
- PCL滤波介绍(2)
- VS2019生成C++开发的exe文件可以在无VS的PC上运行的方法
- 通过python的ConfigParse模块读写ini配置文件
- Rocksdb 的 BlobDB key-value 分离存储插件
- MIT 6.824 Lab2A (raft) -- Leader Election
- google gflags的参数解析,便捷实用
- 【刷题】BZOJ 4516 [Sdoi2016]生成魔咒
- 【Web API系列教程】1.2 — Web API 2中的Action Results
- Python函数中的参数(一)
- sendStickyBroadcast和sendStickyOrderedBroadcast