本文首发于个人博客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. django测试开发-1.开始Hello django!

    用python开发出一个web页面的时候,需要找一个支持python语言的web框架.django框架有丰富的文档和学习资料,也是非常成熟的web开发框架,本篇写一个简单的“hello django! ...

  2. day10整理(面对对象,过程,类和对象)

    目录 一 回顾 (一)定义函数 (二)定义函数的三种形式 1.空函数 2.有参函数 3.无参函数 (三)函数的返回值 (四)函数的参数 1.形参 2.实参 二 面向过程编程 三 面向对象过程 四 类和 ...

  3. Java基础(十四)代理(Proxy)

    1.为什么要使用代理 代理可以在运行时创建一个实现了一组给定接口的新类.这种功能只有在编译时无法确定需要实现哪个接口时才有必要使用. 假设有一个表示接口的Class对象(有可能只包含一个接口),它的确 ...

  4. gulp源码分析

    一.整体结构分析 整体结构 通过在nodejs环境对源码的打印,我们最终得到的gulp实例行如下图.那么我们gulp实例上的属性和方法是如何生成的呢? Gulp { domain: null, _ev ...

  5. SpringCloud之链路追踪整合Sleuth(十三)

    前言 SpringCloud 是微服务中的翘楚,最佳的落地方案. 在一个完整的微服务架构项目中,服务之间的调用是很复杂的,当其中某一个服务出现了问题或者访问超时,很 难直接确定是由哪个服务引起的,所以 ...

  6. Flink中接收端反压以及Credit机制 (源码分析)

    先上一张图整体了解Flink中的反压   可以看到每个task都会有自己对应的IG(inputgate)对接上游发送过来的数据和RS(resultPatation)对接往下游发送数据, 整个反压机制通 ...

  7. Tomcat项目部署

    一 之前一直是在ecplise 利用tomcat插件的形式启动项目,这里可以通过选择server.xml和context files两种方式这里选择这两者方式,都是会在tomcat/bin下产生对应的 ...

  8. Spring Boot 2.x实战之StateMachine

    本文首发于个人网站:Spring Boot 2.x实战之StateMachine Spring StateMachine是一个状态机框架,在Spring框架项目中,开发者可以通过简单的配置就能获得一个 ...

  9. 缓存管理之MemoryCache与Redis的使用

    一..MemoryCache介绍 MemoryCache是.Net Framework 4.0开始提供的内存缓存类,使用该类型可以方便的在程序内部缓存数据并对于数据的有效性进行方便的管理, 它通过在内 ...

  10. Python实现自动化监控远程服务器

    最近发现Python课器做很多事情,在监控服务器有其独特的优势,耗费资源少,开发周期短. 首先我们做一个定时或者实时脚本timedtask.py,让其定时监控目标服务器,两种方式: 第一种: #!/u ...