CentOS 7 编译安装Boost

news2025/4/23 2:18:02

1、前提条件

linux平台/CentOS 7 下要编译安装Boost除gcc和gcc-c++之外,还需要两个开发库:bzip2-devel 和python-devel ,因此在安装前应该先保证这两个库已经安装。

安装指令:

yum install bzip2 bzip2-devel bzip2-libs python-devel

CentOS 7安装效果:

[root@localhost ~]# yum install bzip2 bzip2-devel bzip2-libs python-devel
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.163.com
base                                                                                                                     | 3.6 kB  00:00:00
docker-ce-stable                                                                                                         | 3.5 kB  00:00:00
extras                                                                                                                   | 2.9 kB  00:00:00
updates                                                                                                                  | 2.9 kB  00:00:00
(1/2): docker-ce-stable/7/x86_64/primary_db                                                                              | 117 kB  00:00:26
(2/2): updates/7/x86_64/primary_db                                                                                       |  23 MB  00:02:58
软件包 bzip2-libs-1.0.6-13.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
*********

2、安装

Boost 官网下载地址:https://www.boost.org/

将下载的boost 源码:boost_1_83_0_rc1.tar.gz, 上传CentOS 7 指定目录,我的目录地址为:/usr/local/source_code/.

CentOS  7 指令效果:

[root@localhost ~]# cd /usr/local/source_code/
[root@localhost source_code]# ll
总用量 146560
-rw-r--r--. 1 root root  144648962 10月 13 10:33 boost_1_83_0_rc1.tar.gz
drwxr-xr-x. 2 root root         42 9月  18 17:32 c_demo
drwxrwxr-x. 6 root root       4096 10月 10 09:44 hiredis-1.2.0
-rw-r--r--. 1 root root     126216 10月 10 09:42 hiredis-1.2.0.tar.gz
drwxr-xr-x. 2 root root         50 10月 10 10:37 hiredis_demo
drwxr-xr-x. 5  500 users      8192 9月   4 15:28 jpeg-9e
-rw-r--r--. 1 root root    1046935 9月   4 15:23 jpegsrc.v9e.tar.gz
-rw-r--r--. 1 root root    4234219 8月  31 16:22 release-3.4.13.tar.gz
drwxr-xr-x. 2 root root         52 10月 10 12:54 zookeeper_demo
drwxrwxr-x. 8 root root        259 8月  31 16:33 zookeeper-release-3.4.13

解压Boost 源码 并安装,执行如下命令:

# 解压boost 源码
tar -zxvf boost_1_83_0_rc1.tar.gz
# 进入boost 源码目录
cd boost_1_83_0
# 启动 boost 安装指南脚本
 ./bootstrap.sh
# 安装boost 全部 模块
./b2 install --with=all

 CentOS  7 指令效果:

# 进入Boost 源码目录
[root@localhost source_code]# cd boost_1_83_0
# 启动Boost 库安装指南sh
[root@localhost boost_1_83_0]# ./bootstrap.sh
Building B2 engine..

###
###
### Using 'gcc' toolset.
###
###

g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright © 2015 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。

###
###

> g++ -x c++ -std=c++11 -O2 -s -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filesys.cpp filent.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam_strings.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp startup.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp -o b2

tools/build/src/engine/b2
Detecting Python version... 2.7
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... /usr
Generating B2 configuration in project-config.jam for gcc...

Bootstrapping is done. To build, run:

    ./b2

To generate header files, run:

    ./b2 headers
******
# 安装Boost 模块
[root@localhost boost_1_83_0]# ./b2 install --with=all
Performing configuration checks

    - default address-model    : 64-bit [1]
    - default architecture     : x86 [1]
    - compiler supports SSE2   : yes [2]
    - compiler supports SSE4.1 : yes [2]
    - has std::atomic_ref      : no [2]
    - has -Wl,--no-undefined   : yes [2]
    - has statx                : no [2]
    - has statx syscall        : no [2]
    - has init_priority attribute : yes [2]
    - has stat::st_blksize     : yes [2]
    - has stat::st_mtim        : yes [2]
    - has stat::st_mtimensec   : no [2]
    - has stat::st_mtimespec   : no [2]
    - has stat::st_birthtim    : no [2]
    - has stat::st_birthtimensec : no [2]
    - has stat::st_birthtimespec : no [2]
    - has fdopendir(O_NOFOLLOW) : yes [2]
    - has dirent::d_type       : yes [2]
    - has POSIX *at APIs       : yes [2]
    - cxx11_auto_declarations  : no [2]
    - cxx11_auto_declarations  : no [3]
    - has_icu builds           : yes [2]
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam.
note: to suppress this message, pass "--without-graph_parallel" to bjam.
    - zlib                     : yes
    - bzip2                    : yes
    - lzma                     : no
    - zstd                     : no
    - has_lzma_cputhreads builds : no [2]
    - cxx11_constexpr          : no [2]
    - cxx11_constexpr          : no [3]
    - iconv (libc)             : yes [2]
    - icu                      : yes [2]
    - iconv (libc)             : yes [3]
******

3、Boost 快速上手Demo

在指定目录(/usr/local/source_code) ,创建boost 测试目录(boost_demo)。指令如下:

[root@localhost source_code]# mkdir boost_demo
[root@localhost source_code]# cd boost_demo/
[root@localhost boost_demo]# ll
总用量 0

在boost_demo 目录下,创建boost 测试程序:accumulators_demo.cpp。指令如下:

[root@localhost boost_demo]# vi accumulators_demo.cpp

编辑 accumulators_demo.cpp 文件内容如下:

#include <iostream>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/moment.hpp>
using namespace boost::accumulators;

int main()
{
    // Define an accumulator set for calculating the mean and the
    // 2nd moment ...
    accumulator_set<double, stats<tag::mean, tag::moment<2> > > acc;

    // push in some data ...
    acc(1.2);
    acc(2.3);
    acc(3.4);
    acc(4.5);

    // Display the results ...
    std::cout << "Mean:   " << mean(acc) << std::endl;
    std::cout << "Moment: " << moment<2>(acc) << std::endl;

    return 0;
}

 编译accumulators_demo.cpp 文件并执行。

[root@localhost boost_demo]# g++ accumulators_demo.cpp -o accumulators_demo
In file included from /usr/local/include/boost/function/detail/prologue.hpp:12:0,
                 from /usr/local/include/boost/function.hpp:30,
                 from /usr/local/include/boost/parameter/aux_/tagged_argument.hpp:88,
                 from /usr/local/include/boost/parameter/aux_/tag.hpp:11,
                 from /usr/local/include/boost/parameter/keyword.hpp:10,
                 from /usr/local/include/boost/parameter/nested_keyword.hpp:10,
                 from /usr/local/include/boost/accumulators/accumulators_fwd.hpp:229,
                 from /usr/local/include/boost/accumulators/framework/accumulator_set.hpp:29,
                 from /usr/local/include/boost/accumulators/accumulators.hpp:12,
                 from accumulators_demo.cpp:2:
/usr/local/include/boost/function/detail/requires_cxx11.hpp:18:192: 附注:#pragma message:C++03 support was deprecated in Boost.Function 1.82 and will be removed in Boost.Function 1.84. Please open an issue in https://github.com/boostorg/function if you want it retained.
 BOOST_PRAGMA_MESSAGE("C++03 support was deprecated in Boost.Function 1.82 and will be removed in Boost.Function 1.84. Please open an issue in https://github.com/boostorg/function if you want it retained.")
                                                                                                                                                                                                ^
In file included from /usr/local/include/boost/bind/mem_fn.hpp:24:0,
                 from /usr/local/include/boost/mem_fn.hpp:22,
                 from /usr/local/include/boost/function/detail/prologue.hpp:19,
                 from /usr/local/include/boost/function.hpp:30,
                 from /usr/local/include/boost/parameter/aux_/tagged_argument.hpp:88,
                 from /usr/local/include/boost/parameter/aux_/tag.hpp:11,
                 from /usr/local/include/boost/parameter/keyword.hpp:10,
                 from /usr/local/include/boost/parameter/nested_keyword.hpp:10,
                 from /usr/local/include/boost/accumulators/accumulators_fwd.hpp:229,
                 from /usr/local/include/boost/accumulators/framework/accumulator_set.hpp:29,
                 from /usr/local/include/boost/accumulators/accumulators.hpp:12,
                 from accumulators_demo.cpp:2:
/usr/local/include/boost/bind/detail/requires_cxx11.hpp:18:180: 附注:#pragma message:C++03 support was deprecated in Boost.Bind 1.82 and will be removed in Boost.Bind 1.84. Please open an issue in https://github.com/boostorg/bind if you want it retained.
 BOOST_PRAGMA_MESSAGE("C++03 support was deprecated in Boost.Bind 1.82 and will be removed in Boost.Bind 1.84. Please open an issue in https://github.com/boostorg/bind if you want it retained.")
                                                                                                                                                                                    ^
In file included from /usr/local/include/boost/typeof/typeof.hpp:16:0,
                 from /usr/local/include/boost/accumulators/numeric/functional.hpp:22,
                 from /usr/local/include/boost/accumulators/statistics/mean.hpp:14,
                 from accumulators_demo.cpp:4:
/usr/local/include/boost/typeof/detail/requires_cxx11.hpp:14:102: 附注:#pragma message:C++03 support was deprecated in Boost.Typeof 1.82 and will be removed in Boost.Typeof 1.84.
 BOOST_PRAGMA_MESSAGE("C++03 support was deprecated in Boost.Typeof 1.82 and will be removed in Boost.Typeof 1.84.")
                                                                                                      ^
[root@localhost boost_demo]# ll
总用量 244
-rwxr-xr-x. 1 root root 245128 10月 13 10:57 accumulators_demo
-rw-r--r--. 1 root root    678 10月 13 10:53 accumulators_demo.cpp
[root@localhost boost_demo]# ./accumulators_demo
Mean:   2.85
Moment: 9.635

4、Boost  常用库

Boost 是一组扩展了 C++ 功能的库。常用的包括:

1. Boost.Asio:包含了一套网络和底层 I/O 编程的接口,支持同步、异步操作。

2. Boost.Unordered:提供了类似 C++11 中的 std::unordered_map, std::unordered_set 等的无序容器。

3. Boost.Thread:封装了线程相关的接口,如线程类、互斥量、条件变量等。

4. Boost.Python:扩展了 Python/C++ 的转换机制,以便于在 Python 和 C++之间进行进行更灵活的程序集成。

5. Boost.Smart_Ptr:包含智能指针,如 shared_ptr,weak_ptr,scoped_ptr 等用于资源管理的类。

6. Boost.Filesystem:提供一套跨平台的文件系统访问方法。

7. Boost.Graph:提供一套图数据结构及相关算法。

8. Boost.Regex:封装了正则表达式的类。

9. Boost.Log:提供一套跨平台的日志库。

10. Boost.Date_Time:时间和日期库,提供一种简单、易于操作的方式来处理时间和日期。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1087530.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

学习开发一个RISC-V上的操作系统(汪辰老师) — 01-helloRVOS程序讲解

前言 &#xff08;1&#xff09;此系列文章是跟着汪辰老师的RISC-V课程所记录的学习笔记。 &#xff08;2&#xff09;该课程相关代码gitee链接&#xff1b; &#xff08;3&#xff09;PLCT实验室实习生长期招聘&#xff1a;招聘信息链接 &#xff08;4&#xff09; start.S &a…

SpringBoot项目入门: IDEA 创建SpringBoot项目

方式1:在线创建项目 https://start.spring.io/ 环境准备 &#xff08;1&#xff09;JDK 环境必须是 1.8 及以上&#xff0c;传送门&#xff1a;jdk1.8.191 下载&#xff08;2&#xff09;后面要使用到 Maven 管理工具 3.2.5 及以上版本&#xff08;3&#xff09;开发工具建议…

leetcode-279. 完全平方数

1. 题目链接 链接: 题目链接 2. 解答 #include <stdio.h> #include <stdlib.h> #include <stdbool.h>bool issquare(int n) {if (n 1 || n 4) return true;if (n 2 || n 3) return false;for (int i 3; i < n/2; i ) {if (n i*i) return true;}…

【HCIE】12.VXLAN

VXLAN&#xff0c;是一种IP VPN&#xff0c;每台设备几乎都支持IP&#xff0c;而MPLS会有很多设备不会支持&#xff0c;所以VXLAN是使用的较多。 采用MAC in UDP封装方式&#xff0c;MAC指的是原始数据的以太头部被封装到新的UDP头部里面。是基于三层的一个虚拟网络。 技术背…

13.SpringBoot项目之Service层

SpringBoot项目之Service层 JavaEE三层架构 为了项目维护方便&#xff0c;为了项目开发便利。三层架构功能控制器层&#xff1a;controller方便和前端数据进行交互业务层&#xff1a;service处理各种业务持久化层&#xff1a;mapper和数据库进行数据交互 抽取出service层 按…

华为汪涛:5.5G时代UBB目标网,跃升数字生产力

[阿联酋&#xff0c;迪拜&#xff0c;2023年10月12日] 在2023全球超宽带高峰论坛上&#xff0c;华为常务董事、ICT基础设施业务管理委员会主任汪涛发表了“5.5G时代UBB目标网&#xff0c;跃升数字生产力”的主题发言&#xff0c;分享了超宽带产业的最新思考与实践&#xff0c;探…

Ubuntu 23.10 Beta 镜像开放下载

导读Canonical放出了 Ubuntu 23.10 Beta 镜像&#xff0c;此外 Edubuntu、Kubuntu、Lubuntu、Ubuntu Budgie、Ubuntu Cinnamon、Ubuntu Kylin、Ubuntu MATE、Ubuntu Studio、Ubuntu Unity 和 Xubuntu 等风味版本也同步放出镜像。 近日消息&#xff0c;Canonical 放出了 Ubuntu …

【1++的Linux】之文件(二)

&#x1f44d;作者主页&#xff1a;进击的1 &#x1f929; 专栏链接&#xff1a;【1的Linux】 文章目录 一&#xff0c;文件描述符二&#xff0c;重定向三&#xff0c;理解Linux下一切皆文件 一&#xff0c;文件描述符 我们先来看一段代码&#xff1a; #include<unistd.h&g…

什么是CDN内容分发网络?如何做到加速的?

这里写目录标题 CDN如何做到加速的&#xff1f; CDN content delivery network内容分发网络是建立并覆盖在承载网上&#xff0c;由遍布全球的边缘节点服务器群组成的分布式网络。 CDN将源站资源缓存在遍布全球的边缘加速节点服务器上&#xff0c;当客户需要访问和获取资源的时…

如何使用Net2FTP搭建免费web文件管理器打造个人网盘

文章目录 1.前言2. Net2FTP网站搭建2.1. Net2FTP下载和安装2.2. Net2FTP网页测试 3. cpolar内网穿透3.1.Cpolar云端设置3.2.Cpolar本地设置 4.公网访问测试5.结语 1.前言 文件传输可以说是互联网最主要的应用之一&#xff0c;特别是智能设备的大面积使用&#xff0c;无论是个人…

助力乡村教育 泰格智能AI英语开展捐赠实施线上培训

2023年10月11日晚8点至9点&#xff0c;泰格智能AI英语创始人李勤骞老师举行了一场为期一小时的线上培训&#xff0c;旨在详细解答泰格智能AI英语联合中国善网捐赠千词切APP训练账号的意义&#xff0c;探讨乡村教育、学习英语的现状和方法&#xff0c;以及项目的实施和落地要求。…

阿里健康携手15家药企发起“慢病减压计划”,为职场人的健康“减负”

近年来&#xff0c;慢性疾病患者的发病年龄正在逐年递减。一组来自阿里健康研究院内部分析数据印证了这一趋势。数据显示&#xff0c;当代80后职场人群中&#xff0c;三成用户购买过慢病药品。 30-39岁已经成为肝胆、心脑等相关疾病药品的购药主力人群 。35-39岁是高血压疾病药…

204、RabbitMQ 之 使用 topic 类型的 Exchange 实现通配符路由

目录 ★ 使用topic实现通配符路由代码演示topic通配符类型的Exchange代码演示:ConstantUtilConnectionUtilProducerConsumer01执行结果生产者消费者01消费者02 完整代码&#xff1a;ConstantUtilConnectionUtilProducerConsumer01Consumer02pom.xml ★ 使用topic实现通配符路由…

Linux系统移植框架简介

一、系统移植简介 系统移植就是给开发板安装一个linux系统。需要从官方下载u-boot源码&#xff0c;linux内核源码&#xff0c;根文件系统的源码&#xff0c;对源码进行配置和编译&#xff0c;生成对应的源码的镜像文件&#xff0c;将镜像文件部署到开发板中&#xff0c;使开发…

上海亚商投顾:沪指高开高走 锂电等新能源赛道大反攻

上海亚商投顾前言&#xff1a;无惧大盘涨跌&#xff0c;解密龙虎榜资金&#xff0c;跟踪一线游资和机构资金动向&#xff0c;识别短期热点和强势个股。 一.市场情绪 沪指昨日高开后强势震荡&#xff0c;创业板指盘中一度翻绿&#xff0c;随后探底回升再度走高。碳酸锂期货合约…

制药行业中的设备管理系统和CSV最佳实践

在制药行业&#xff0c;合规性和质量是关键要素&#xff0c;而设备管理和计算机化系统验证&#xff08;CSV&#xff09;是确保这些要素的关键。之前我们介绍过设备健康管理系统如何帮助制药企业实现CSV合规性>>PreMaint设备健康管理系统&#xff1a;实现制药企业的CSV合规…

Activiti 8.0.0 发布,业务流程管理与工作流系统

导读Activiti 8.0.0 现已发布。Activiti 是一个业务流程管理 (BPM) 和工作流系统&#xff0c;适用于开发人员和系统管理员。其核心是超快速、稳定的 BPMN2 流程引擎。Activiti 可以在任何 Java 应用程序、服务器、集群或云中运行&#xff0c;与 Spring 完美集成。 具体更新内容…

声音克隆,定制自己的声音,使用最新版Bert-VITS2的云端训练+推理记录

说明 本次训练服务器使用Google Colab T4 GPUBert-VITS2库为&#xff1a;https://github.com/fishaudio/Bert-VITS2&#xff0c;其更新较为频繁&#xff0c;使用其2023.10.12的commit版本&#xff1a;主要参考&#xff1a;B站诸多大佬视频&#xff0c;CSDN:https://blog.csdn.…

Visual Studio主题颜色及字体

一、打开VS上方的工具 二、选择“选项” 三、在“常规”中选择“颜色主题” 一共四个颜色供大家参考&#xff1a; ①深色 ②浅色 ③蓝色 ④蓝&#xff08;额外对比度&#xff09; 四、字体设置 左边环境中下划