本文首发于个人博客https://kezunlin.me/post/d5d4a460/,欢迎阅读!

compile boost 1.66.0 from source on ubuntu 16.04

Guide

apt-get

# 1.58 for ubuntu 16.04
sudo apt-get install libboost-all-dev

compile from source

sudo apt-get -y purge libboost-all-dev

wget https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz

tar xzvf boost_1_66_0.tar.gz
cd boost_1_66_0/ sudo apt-get update
sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev ./bootstrap.sh --prefix=/usr/local/ ./b2 --help ./b2 -j8 variant=release link=shared threading=multi runtime-link=shared
sudo ./b2 -j8 install

thread example

thread_demo.cpp

//#include <boost/thread/thread.hpp>
//#include <boost/thread/mutex.hpp>
//#include <boost/bind/bind.hpp>
#include <iostream> #include <boost/thread.hpp>
#include <boost/bind.hpp> boost::mutex io_mutex; void count(int id)
{
for (int i = 0; i < 10; i++)
{
boost::mutex::scoped_lock lock(io_mutex);
std::cout << id << ":" << i << std::endl;
}
} int main(int argc, char* argv[])
{
boost::thread thrd1(boost::bind(&count, 1));
boost::thread thrd2(boost::bind(&count, 2));
thrd1.join();
thrd2.join();
return 0;
}

CMakeLists.txt

cmake_minimum_required (VERSION 2.6)

project (thread_main)
enable_language(C)
enable_language(CXX) set(Boost_USE_RELEASE_LIBS ON)
#set(Boost_USE_STATIC_LIBS OFF) # use .a or .so file
set(Boost_USE_MULTITHREAD ON) # Find Boost package 1.5.8 or 1.6.6
find_package(Boost 1.5.8 REQUIRED COMPONENTS serialization date_time system filesystem thread timer)
include_directories(${Boost_INCLUDE_DIRS}) add_executable (thread_main
thread_main.cpp
) target_link_libraries (thread_main
${Boost_LIBRARIES}
)

thread pool

see thread pool with boost

Reference

History

  • 20180131: created.

Copyright

Ubuntu 16.04源码编译boost库 编写CMakeLists.txt | compile boost 1.66.0 from source on ubuntu 16.04的更多相关文章

  1. [Windows篇] 在windows 10上源码编译gtest 并编写CMakeLists.txt

    本文首发于个人博客https://kezunlin.me/post/aca50ff8/,欢迎阅读! compile gtest on windows 10 Guide compile gtest on ...

  2. ubuntu 14.04 源码编译mysql-5.7.17

    环境为 Ubuntu 12.04 64 位的桌面版 编译的mysql 版本为 5.7.18 首先需要安装一下依赖包 sudo apt-get install libncurses5-dev cmake ...

  3. [笔记] Ubuntu 18.04源码编译安装OpenCV 4.0流程

    标准常规安装方法安装的OpenCV版本比较低,想尝鲜使用4.0版本,只好源码安装. 安装环境 OS:Ubuntu 18.04 64 bit 显卡:NVidia GTX 1080 CUDA:10.0 c ...

  4. ubuntu 14.04 源码编译postgresql

    环境 ubuntu 14.04 桌面版 postgresql 源码下载链接,本教程是使用postgresql 9.3.4 进行编译的 http://www.postgresql.org/ftp/sou ...

  5. Ubuntu 16.04 源码编译安装PHP7+swoole

    备注: Ubuntu 16.04 Server 版安装过程图文详解 Ubuntu16镜像地址: 链接:https://pan.baidu.com/s/1XTVS6BdwPPmSsF-cYF6B7Q 密 ...

  6. ubuntu 16.04源码编译和配置caffe详细教程 | Install and Configure Caffe on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/b90033a9/,欢迎阅读! Install and Configure Caffe on ubuntu 16.04 Series ...

  7. Ubuntu 16.04 源码编译安装PHP7

    一.下载PHP7的最新版源码 php7.0.9  下载地址 http://php.net/get/php-7.0.9.tar.gz/from/a/mirror 二.解压 tar -zxf /tmp/p ...

  8. Ubuntu 16.04源码编译安装nginx 1.10.0

    一.下载相关的依赖库 pcre 下载地址 http://120.52.73.43/jaist.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.t ...

  9. ubuntu 16.04源码编译OpenCV教程 | compile opencv on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/15f5c3e8/,欢迎阅读! compile opencv on ubuntu 16.04 Series Part 1: comp ...

随机推荐

  1. Cassandra官方介绍及安装

    Cassandra官方介绍及安装 这个数据库有很高的伸缩性和可用性,你完全不需要向性能妥协.在硬件或者云设施上做修改 官网:Cassandra官网 一.简介 cassandra这个数据库有很高的伸缩性 ...

  2. Mongoose-modified-at 时间自动记录插件介绍

    Mongoose-modified-at 是一款自动更新字段变化时间并记录到数据库中的 Mongoose 插件,类似 Mongoose 自带的 timestamps 功能. 使用场景 让我们考虑一个场 ...

  3. redis入门(二)

    目录 redis入门(二) 前言 持久化 RDB AOF 持久化文件加载 高可用 哨兵 流程 安装部署 配置技巧 集群 原理 集群搭建 参考文档 redis入门(二) 前言 在redis入门(一)简单 ...

  4. Redis(十一)缓存设计

    一.缓存的收益和成本 左侧为客户端直接调用存储层的架构,右侧为比较典型的缓存层+存储层架构, 缓存加入后带来的收益如下: 加速读写:因为缓存通常都是全内存的(例如Redis.Memcache),而存储 ...

  5. Android 正则表达式,Pattern,Matcher基本使用

    Pattern类:      Pattern的创建:      Pattern pattern =Pattern.complie(String regex)     参数说明:regex:是一个正则表 ...

  6. C#开发命令执行驱动程序 之 读入命令行参数

    /// <summary> /// 在cmd窗体内执行如下: /// OrderDriverApp.exe Order Driver App /// 返回: /// The args ar ...

  7. 实战SpringCloud响应式微服务系列教程(第十章)响应式RESTful服务完整代码示例

    本文为实战SpringCloud响应式微服务系列教程第十章,本章给出响应式RESTful服务完整代码示例.建议没有之前基础的童鞋,先看之前的章节,章节目录放在文末. 1.搭建响应式RESTful服务. ...

  8. JVM垃圾收集策略与算法

    垃圾收集策略与算法 程序计数器.虚拟机栈.本地方法栈随线程而生,也随线程而灭:栈帧随着方法的开始而入栈,随着方法的结束而出栈.这几个区域的内存分配和回收都具有确定性,在这几个区域内不需要过多考虑回收的 ...

  9. java里的单例实现

    枚举实现单例 线程安全,调用效率高,不能延时加载,可以天然的防止反射和反序列化调用 public enum SingletonFactory { //枚举元素本身就是单例 INSTANCE; //添加 ...

  10. intellij idea - Project Structure 项目结构详解(简单明了)

    IDEA Project Structure 设置 可以点击  按钮,或者使用快捷键 Ctrl + Shift + Alt + S  打开 Project Structure .如下如所示: 项目的左 ...