linux下boost编译
来源:互联网 发布:烈火封神翅膀升级数据 编辑:程序博客网 时间:2024/05/14 07:12
版本选择
选择你想要的版本。这里我用的是boost_1_64_0,在/home目录下下载
$wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
$ tar xvf boost_1_64_0.tar.gz
测试
保存以下代码另存为test.cpp
#include <iostream>#include <boost/smart_ptr.hpp>using namespace std;using namespace boost;int main(){ int* p = new int; shared_ptr<int> sh(p); *p = 123;*sh = 456; cout<<*p<<endl; return 0;}
该程序使用了boost里面shared_ptr智能指针。该库无需编译只需要包含头文件即可以使用
$g++ -I /home/boost_1_64_0 test.cpp
查看需要编译才能使用的库
$ cd boost_1_64_0
$ ./bootstrap.sh --show-libraries //查看需要编译才能使用的库, 显示如下
- atomic
- chrono
- container
- context
- coroutine
- coroutine2
- date_time
- exception
- fiber
- filesystem
- graph
- graph_parallel
- iostreams
- locale
- log
- math
- metaparse
- mpi
- program_options
- python
- random
- regex
- serialization
- signals
- system
- test
- thread
- timer
- type_erasure
- wave
部分编译
$./ bootstrap.sh //生成bjam
$./bjam --toolset=gcc --with-regex //编译regex库,toolset选项指定编译器,如msvc,gcc等
编译完成显示如下:
测试
编辑以下代码另存为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++ --std=c++11 regex.cpp -I /home/boost_1_64_0 -L /home/boost_1_64_0/stage/lib/ -lboost_regex
编译通过,生成可执行程序a.out
完全编译
当项目中用到多个boost库的时候可以选择完全编译,完全编译需要的时间较长
$./bjam--toolset=gcc
生成的库与以上所述部分编译的路径一致,当然也可以编译的选择路径等其他参数,详情请看bjam帮助文档。这里不做介绍。
阅读全文
0 0
- linux下编译boost
- linux下编译BOOST
- linux下编译boost
- linux 下boost编译
- linux 下编译boost
- linux下编译boost
- boost linux下编译
- linux下boost编译
- Linux下boost编译安装
- linux下编译boost.python
- boost在linux下编译
- Linux 下编译使用Boost
- Linux下编译安装BOOST
- Linux下编译安装boost
- Linux下Boost编译安装
- 在linux下编译boost库
- 在linux下编译boost库
- LINUX下BOOST编译(记录一下)
- Android自定义View
- 三种网络工作模式
- java遇到的问题总结
- 如何让imageView铺满屏幕?
- ls命令——目录基本操作
- linux下boost编译
- 服务器车牌云识别使用方案
- Centos 7 安装 Python3.6后yum无法使用的解决方法
- HBase全网最佳学习资料汇总
- Linux--防火墙策略 iptables(续)
- UVA_1600 Patrol Robot
- UVA_439 Knight Moves
- Leetcode题目总结-Linkedlist-题目206和234
- poj 2774 后缀数组