IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> C++知识库 -> c++ boost库 -> 正文阅读

[C++知识库]c++ boost库

一、简介:

????????Boost是为C++语言标准库提供扩展的一些C++程序库的总称。Boost库是一个可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进程的开发引擎之一,是为C++语言标准库提供扩展的一些C++程序库的总称。

? ? ? ? Boost库由C++标准委员会库工作组成员发起,其中有些内容有望成为下一代C++标准库内容。在C++社区中影响甚大,是不折不扣的“准”标准库。

管网:Boost C++ Libraries

HP-EliteDesk-880-G2-TWR:~/boost_1_80_0$ tree -L 1
.
├── boost                #所有boost库头文件,90%以上的boost库源码都在这里
├── boost-build.jam
├── boostcpp.jam
├── boost.css
├── boost.png
├── bootstrap.bat
├── bootstrap.sh
├── doc                  #文档
├── index.htm
├── index.html
├── INSTALL
├── Jamroot
├── libs                 #所有组件的示例/测试/编译代码和说明文档
├── LICENSE_1_0.txt
├── more                 #库作者相关的文档
├── README.md
├── rst.css
├── status               #可用于测试boost库的各个组件
└── tools                #b2、quickbook等一些自带的工具

6 directories, 13 files

boost子目录是最为重要的目录。以头文件的形式分门别类存放了要使用的库代码:?

├─accumulators		#累加器库
├─algorithm			#算法库
├─archive			#序列化库
├─asio				#异步并发库
├─assign			#赋值初始化库
├─atomic			#原子操作库
├─bimap				#双向关联数组
├─bind				#bind表达式
├─chrono			#时间处理库
├─circular_buffer	#循环缓冲区容器
...					#其他库
...
└─xpressive			#正则表达式库

二、编译,安装

2.1、linux平台

HP-EliteDesk-880-G2-TWR:~/boost_1_80_0$ ./bootstrap.sh -h
`./bootstrap.sh\' builds the Boost build system B2 and prepares Boost for
building. This includes setting defaults in the project-config.jam which you
can adjust prior to invoking B2.

Usage: ./bootstrap.sh [OPTION]...

Defaults for the options are specified in brackets.

Configuration:
  -h, --help                display this help and exit
  --with-bjam=BJAM          use existing Boost.Jam executable (bjam)
                            [automatically built]
  --with-toolset=TOOLSET    use specific TOOLSET to build B2 and as default
                            for building Boost
                            [automatically detected]
  --show-libraries          show the set of libraries that require build
                            and installation steps (i.e., those libraries
                            that can be used with --with-libraries or
                            --without-libraries), then exit
  --with-libraries=list     build only a particular set of libraries,
                            describing using either a comma-separated list of
                            library names or "all"
                            [all]
  --without-libraries=list  build all libraries except the ones listed []
  --with-icu                enable Unicode/ICU support in Regex
                            [automatically detected]
  --without-icu             disable Unicode/ICU support in Regex
  --with-icu=DIR            specify the root of the ICU library installation
                            and enable Unicode/ICU support in Regex
                            [automatically detected]
  --with-python=PYTHON      specify the Python executable [python]
  --with-python-root=DIR    specify the root of the Python installation
                            [automatically detected]
  --with-python-version=X.Y specify the Python version as X.Y
                            [automatically detected]

Installation directories:
  --prefix=PREFIX           install Boost into the given PREFIX
                            [/usr/local]
  --exec-prefix=EPREFIX     install Boost binaries into the given EPREFIX
                            [PREFIX]

More precise control over installation directories:
  --libdir=DIR              install libraries here [EPREFIX/lib]
  --includedir=DIR          install headers here [PREFIX/include]

某些库不需要编译,包含头文件就可以使用,有些需要编译后才能使用。

以下是必须编译成静态库或动态库才能使用的boost库:

HP-EliteDesk-880-G2-TWR:~/boost_1_80_0$ ./bootstrap.sh --show-libraries
Building B2 engine..

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

g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


###
###

> 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

The following Boost libraries have portions that require a separate build
and installation step. Any library not listed here can be used by including
the headers only.

The Boost libraries requiring separate building and installation are:
    - atomic
    - chrono
    - container
    - context
    - contract
    - coroutine
    - date_time
    - exception
    - fiber
    - filesystem
    - graph
    - graph_parallel
    - headers
    - iostreams
    - json
    - locale
    - log
    - math
    - mpi
    - nowide
    - program_options
    - python
    - random
    - regex
    - serialization
    - stacktrace
    - system
    - test
    - thread
    - timer
    - type_erasure
    - wave

三、使用

先使用不需要编译的库,直接使用头文件,测试代码:

#include <boost/lexical_cast.hpp> //不需要单独编译的库    
#include <iostream>     
  
using namespace std;  
  
int main()  
{  
    using boost::lexical_cast;   
  
    int a=lexical_cast<int>("123");   
    double b=lexical_cast<double>("123.0123456789");   
    string s0=lexical_cast<string>(a);   
    string s1=lexical_cast<string>(b);   
    cout<<"number: "<<a<<"  "<<b<<endl;   
    cout<<"string: "<<s0<<"  "<<s1<<endl;   
    int c=0;   
    try{    
        c=lexical_cast<int>("abcd");   
    }    
    catch(boost::bad_lexical_cast& e){    
        cout<<e.what()<<endl;   
    }  
  
    return 0;   
}  

四、裁剪

假设我们允许程序员用A、B、C、D这样四个模块,那么可以这样:

bcp --boost:<boost-root-directory>?A B C D?<output-directory>

这里A、B、C、D可以是:

Boost的头文件名。如: boost/shared_ptr.hpp

Boost的库名。如:regex

Boost的头文件标题:boost/shared_ptr 或者 shared_ptr

如果是在boost根目录下,那指定boost目录的参数也可以省去。

使用 bcp 裁剪 boost 库_丛继晔的博客-CSDN博客_boost 裁剪

boost裁剪和编译

ref:

嵌入式Linux开发的编程语言选择 - 知乎

Boost库的简介与安装_问我学院的博客-CSDN博客

嵌入式linux开发,boost移植,boost交叉编译_寞水的博客-CSDN博客_boost移植

boost库不安装使用和安装使用_fengyun_w的博客-CSDN博客

windows下编译和安装boost库 - rangers - 博客园

Boost Arm 交叉编译_FlyWine的博客-CSDN博客_arm boost

boost/config.hpp文件详解 - 莫水千流 - 博客园

  C++知识库 最新文章
【C++】友元、嵌套类、异常、RTTI、类型转换
通讯录的思路与实现(C语言)
C++PrimerPlus 第七章 函数-C++的编程模块(
Problem C: 算法9-9~9-12:平衡二叉树的基本
MSVC C++ UTF-8编程
C++进阶 多态原理
简单string类c++实现
我的年度总结
【C语言】以深厚地基筑伟岸高楼-基础篇(六
c语言常见错误合集
上一篇文章      下一篇文章      查看所有文章
加:2022-09-04 00:51:43  更:2022-09-04 00:55:50 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/19 8:38:02-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码