【C++】CentOS环境搭建-编译安装Boost库(附CMAKE编译文件)

news2024/11/27 7:33:52

【C++】环境搭建-编译安装Boost库

  • Boost库简介
  • Boost库安装
    • 通过YUM安装(版本较低 V1.53.0)
    • 通过编译安装(官网最新版本1.85.0)
      • 1.安装相关依赖
      • 2.查询官网下载最新安装包并解压
      • 3.编译Boost
      • 4.安装Boost库到系统路径
  • Boost库验证

Boost库简介

Boost库是为C++语言标准库提供扩展的一些C++程序库的总称。
Boost库由Boost社区组织开发、维护。其目的是为C++程序员提供免费、同行审查的、可移植的程序库。Boost库可以与C++标准库共同工作,并且为其提供扩展功能。Boost库使用Boost License来授权使用,根据该协议,商业或非商业的使用都是允许并鼓励的。
Boost社区建立的初衷之一就是为C++的标准化工作提供可供参考的实现,Boost社区的发起人Dawes本人就是C++标准委员会的成员之一。在Boost库的开发中,Boost社区也在这个方向上取得了丰硕的成果。在送审的C++标准库TR1中,有十个Boost库成为标准库的候选方案。在更新的TR2中,有更多的Boost库被加入到其中。从某种意义上来讲,Boost库成为具有实践意义的准标准库。
大部分boost库功能的使用只需包括相应头文件即可,少数(如正则表达式库,文件系统库等)需要链接库。里面有许多具有工业强度的库,如graph库。
很多Boost中的库功能堪称对语言功能的扩展,其构造用尽精巧的手法,不要贸然的花费时间研读。Boost另外一面,比如Graph这样的库则是具有工业强度,结构良好,非常值得研读的精品代码,并且也可以放心的在产品代码中多多利用。

Boost库安装

通过YUM安装(版本较低 V1.53.0)

  1. 升级YUM到最新版本
sudo yum update
  1. 安装boost开发版
sudo yum install boost-devel

安装效果如下:

[root@localhost ~]# sudo yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:1.18.8-1.el7 will be updated
---> Package NetworkManager.x86_64 1:1.18.8-2.el7_9 will be an update
---> Package NetworkManager-libnm.x86_64 1:1.18.8-1.el7 will be updated
---> Package NetworkManager-libnm.x86_64 1:1.18.8-2.el7_9 will be an update
---> Package NetworkManager-team.x86_64 1:1.18.8-1.el7 will be updated
---> Package NetworkManager-team.x86_64 1:1.18.8-2.el7_9 will be an update
---> Package NetworkManager-tui.x86_64 1:1.18.8-1.el7 will be updated
---> Package NetworkManager-tui.x86_64 1:1.18.8-2.el7_9 will be an update
---> Package bash.x86_64 0:4.2.46-34.el7 will be updated
---> Package bash.x86_64 0:4.2.46-35.el7_9 will be an update
---> Package bind-export-libs.x86_64 32:9.11.4-26.P2.el7 will be updated
---> Package bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.15 will be an update
---> Package binutils.x86_64 0:2.27-44.base.el7 will be updated
---> Package binutils.x86_64 0:2.27-44.base.el7_9.1 will be an update
---> Package ca-certificates.noarch 0:2020.2.41-70.0.el7_8 will be updated
---> Package ca-certificates.noarch 0:2023.2.60_v7.0.306-72.el7_9 will be an update
---> Package centos-release.x86_64 0:7-9.2009.0.el7.centos will be updated
---> Package centos-release.x86_64 0:7-9.2009.1.el7.centos will be an update
---> Package coreutils.x86_64 0:8.22-24.el7 will be updated
---> Package coreutils.x86_64 0:8.22-24.el7_9.2 will be an update
---> Package cronie.x86_64 0:1.4.11-23.el7 will be updated
---> Package cronie.x86_64 0:1.4.11-25.el7_9 will be an update
---> Package cronie-anacron.x86_64 0:1.4.11-23.el7 will be updated
---> Package cronie-anacron.x86_64 0:1.4.11-25.el7_9 will be an update
---> Package cyrus-sasl-lib.x86_64 0:2.1.26-23.el7 will be updated
---> Package cyrus-sasl-lib.x86_64 0:2.1.26-24.el7_9 will be an update
---> Package device-mapper.x86_64 7:1.02.170-6.el7 will be updated
---> Package device-mapper.x86_64 7:1.02.170-6.el7_9.5 will be an update
---> Package device-mapper-event.x86_64 7:1.02.170-6.el7 will be updated
---> Package device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.170-6.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update
---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-3.el7 will be updated
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 will be an update
---> Package dhclient.x86_64 12:4.2.5-82.el7.centos will be updated
---> Package dhclient.x86_64 12:4.2.5-83.el7.centos.1 will be an update
---> Package dhcp-common.x86_64 12:4.2.5-82.el7.centos will be updated
---> Package dhcp-common.x86_64 12:4.2.5-83.el7.centos.1 will be an update
---> Package dhcp-libs.x86_64 12:4.2.5-82.el7.centos will be updated
---> Package dhcp-libs.x86_64 12:4.2.5-83.el7.centos.1 will be an update
---> Package diffutils.x86_64 0:3.3-5.el7 will be updated
---> Package diffutils.x86_64 0:3.3-6.el7_9 will be an update
---> Package dmidecode.x86_64 1:3.2-5.el7 will be updated
---> Package dmidecode.x86_64 1:3.2-5.el7_9.1 will be an update
---> Package firewalld.noarch 0:0.6.3-11.el7 will be updated
---> Package firewalld.noarch 0:0.6.3-13.el7_9 will be an update
---> Package firewalld-filesystem.noarch 0:0.6.3-11.el7 will be updated
---> Package firewalld-filesystem.noarch 0:0.6.3-13.el7_9 will be an update
---> Package freetype.x86_64 0:2.8-14.el7 will be updated
---> Package freetype.x86_64 0:2.8-14.el7_9.1 will be an update
---> Package glib2.x86_64 0:2.56.1-7.el7 will be updated
---> Package glib2.x86_64 0:2.56.1-9.el7_9 will be an update
---> Package grub2.x86_64 1:2.02-0.86.el7.centos will be updated
---> Package grub2.x86_64 1:2.02-0.87.0.2.el7.centos.14 will be an update
---> Package grub2-common.noarch 1:2.02-0.86.el7.centos will be updated
---> Package grub2-common.noarch 1:2.02-0.87.0.2.el7.centos.14 will be an update
---> Package grub2-pc.x86_64 1:2.02-0.86.el7.centos will be updated
---> Package grub2-pc.x86_64 1:2.02-0.87.0.2.el7.centos.14 will be an update
---> Package grub2-pc-modules.noarch 1:2.02-0.86.el7.centos will be updated
---> Package grub2-pc-modules.noarch 1:2.02-0.87.0.2.el7.centos.14 will be an 
.....
pdated:
  NetworkManager.x86_64 1:1.18.8-2.el7_9                    NetworkManager-libnm.x86_64 1:1.18.8-2.el7_9          NetworkManager-team.x86_64 1:1.18.8-2.el7_9            
  NetworkManager-tui.x86_64 1:1.18.8-2.el7_9                bash.x86_64 0:4.2.46-35.el7_9                         bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.15       
  binutils.x86_64 0:2.27-44.base.el7_9.1                    ca-certificates.noarch 0:2023.2.60_v7.0.306-72.el7_9  centos-release.x86_64 0:7-9.2009.1.el7.centos          
  coreutils.x86_64 0:8.22-24.el7_9.2                        cronie.x86_64 0:1.4.11-25.el7_9                       cronie-anacron.x86_64 0:1.4.11-25.el7_9                
  cyrus-sasl-lib.x86_64 0:2.1.26-24.el7_9                   device-mapper.x86_64 7:1.02.170-6.el7_9.5             device-mapper-event.x86_64 7:1.02.170-6.el7_9.5        
  device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5      device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5        device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 
  dhclient.x86_64 12:4.2.5-83.el7.centos.1                  dhcp-common.x86_64 12:4.2.5-83.el7.centos.1           dhcp-libs.x86_64 12:4.2.5-83.el7.centos.1              
  diffutils.x86_64 0:3.3-6.el7_9                            dmidecode.x86_64 1:3.2-5.el7_9.1                      firewalld.noarch 0:0.6.3-13.el7_9                      
  firewalld-filesystem.noarch 0:0.6.3-13.el7_9              freetype.x86_64 0:2.8-14.el7_9.1                      glib2.x86_64 0:2.56.1-9.el7_9                          
  grub2.x86_64 1:2.02-0.87.0.2.el7.centos.14                grub2-common.noarch 1:2.02-0.87.0.2.el7.centos.14     grub2-pc.x86_64 1:2.02-0.87.0.2.el7.centos.14          
  grub2-pc-modules.noarch 1:2.02-0.87.0.2.el7.centos.14     grub2-tools.x86_64 1:2.02-0.87.0.2.el7.centos.14      grub2-tools-extra.x86_64 1:2.02-0.87.0.2.el7.centos.14 
  grub2-tools-minimal.x86_64 1:2.02-0.87.0.2.el7.centos.14  gzip.x86_64 0:1.5-11.el7_9                            initscripts.x86_64 0:9.49.53-1.el7_9.1                 
  iprutils.x86_64 0:2.4.17.1-3.el7_7                        iwl100-firmware.noarch 0:39.31.5.1-82.el7_9           iwl1000-firmware.noarch 1:39.31.5.1-82.el7_9           
  iwl105-firmware.noarch 0:18.168.6.1-82.el7_9              iwl135-firmware.noarch 0:18.168.6.1-82.el7_9          iwl2000-firmware.noarch 0:18.168.6.1-82.el7_9          
  iwl2030-firmware.noarch 0:18.168.6.1-82.el7_9             iwl3160-firmware.noarch 0:25.30.13.0-82.el7_9         iwl3945-firmware.noarch 0:15.32.2.9-82.el7_9           
  iwl4965-firmware.noarch 0:228.61.2.24-82.el7_9            iwl5000-firmware.noarch 0:8.83.5.1_1-82.el7_9         iwl5150-firmware.noarch 0:8.24.2.2-82.el7_9            
  iwl6000-firmware.noarch 0:9.221.4.1-82.el7_9              iwl6000g2a-firmware.noarch 0:18.168.6.1-82.el7_9      iwl6000g2b-firmware.noarch 0:18.168.6.1-82.el7_9       
  iwl6050-firmware.noarch 0:41.28.5.1-82.el7_9              iwl7260-firmware.noarch 0:25.30.13.0-82.el7_9         kbd.x86_64 0:1.15.5-16.el7_9                           
  kbd-legacy.noarch 0:1.15.5-16.el7_9                       kbd-misc.noarch 0:1.15.5-16.el7_9                     kernel-tools.x86_64 0:3.10.0-1160.118.1.el7            
  kernel-tools-libs.x86_64 0:3.10.0-1160.118.1.el7          kexec-tools.x86_64 0:2.0.15-51.el7_9.3                kpartx.x86_64 0:0.4.9-136.el7_9                        
  libblkid.x86_64 0:2.23.2-65.el7_9.1                       libcroco.x86_64 0:0.6.12-6.el7_9                      libmount.x86_64 0:2.23.2-65.el7_9.1                    
  libsmartcols.x86_64 0:2.23.2-65.el7_9.1                   libssh2.x86_64 0:1.8.0-4.el7_9.1                      libuuid.x86_64 0:2.23.2-65.el7_9.1                     
  libxml2.x86_64 0:2.9.1-6.el7_9.6                          linux-firmware.noarch 0:20200421-82.git78c0348.el7_9  lvm2.x86_64 7:2.02.187-6.el7_9.5                       
  lvm2-libs.x86_64 7:2.02.187-6.el7_9.5                     microcode_ctl.x86_64 2:2.1-73.20.el7_9                nspr.x86_64 0:4.35.0-1.el7_9                           
  nss.x86_64 0:3.90.0-2.el7_9                               nss-pem.x86_64 0:1.0.3-7.el7_9.1                      nss-softokn.x86_64 0:3.90.0-6.el7_9                    
  nss-softokn-freebl.x86_64 0:3.90.0-6.el7_9                nss-sysinit.x86_64 0:3.90.0-2.el7_9                   nss-tools.x86_64 0:3.90.0-2.el7_9                      
  nss-util.x86_64 0:3.90.0-1.el7_9                          openldap.x86_64 0:2.4.44-25.el7_9                     openssh.x86_64 0:7.4p1-23.el7_9                        
  openssh-clients.x86_64 0:7.4p1-23.el7_9                   openssh-server.x86_64 0:7.4p1-23.el7_9                polkit.x86_64 0:0.112-26.el7_9.1                       
  python.x86_64 0:2.7.5-94.el7_9                            python-firewall.noarch 0:0.6.3-13.el7_9               python-libs.x86_64 0:2.7.5-94.el7_9                    
  python-perf.x86_64 0:3.10.0-1160.118.1.el7                rpm.x86_64 0:4.11.3-48.el7_9                          rpm-build-libs.x86_64 0:4.11.3-48.el7_9                
  rpm-libs.x86_64 0:4.11.3-48.el7_9                         rpm-python.x86_64 0:4.11.3-48.el7_9                   rsyslog.x86_64 0:8.24.0-57.el7_9.3                     
  selinux-policy.noarch 0:3.13.1-268.el7_9.2                selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2   sudo.x86_64 0:1.8.23-10.el7_9.3                        
  systemd.x86_64 0:219-78.el7_9.9                           systemd-libs.x86_64 0:219-78.el7_9.9                  systemd-sysv.x86_64 0:219-78.el7_9.9                   
  tuned.noarch 0:2.11.0-12.el7_9                            tzdata.noarch 0:2024a-1.el7                           util-linux.x86_64 0:2.23.2-65.el7_9.1                  
  vim-minimal.x86_64 2:7.4.629-8.el7_9                      virt-what.x86_64 0:1.18-4.el7_9.1                     wpa_supplicant.x86_64 1:2.6-12.el7_9.2                 
  xz.x86_64 0:5.2.2-2.el7_9                                 xz-libs.x86_64 0:5.2.2-2.el7_9                       

Complete!
root@localhost ~]# sudo yum install boost-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package boost-devel.x86_64 0:1.53.0-28.el7 will be installed
--> Processing Dependency: boost(x86-64) = 1.53.0-28.el7 for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_wserialization.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_wserialization-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_wave.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_wave-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_unit_test_framework.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_unit_test_framework-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_timer.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_timer-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_system.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_system-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_signals.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_signals-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_serialization.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_serialization-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_regex.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_regex-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_random.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_random-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_python.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_python-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_program_options.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_program_options-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_prg_exec_monitor.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_prg_exec_monitor-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_math_tr1l.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_math_tr1l-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
--> Processing Dependency: libboost_math_tr1f.so.1.53.0()(64bit) for package: boost-devel-1.53.0-28.el7.x86_64
 Verifying  : boost-test-1.53.0-28.el7.x86_64                                                                                                                      19/23 
  Verifying  : boost-math-1.53.0-28.el7.x86_64                                                                                                                      20/23 
  Verifying  : boost-chrono-1.53.0-28.el7.x86_64                                                                                                                    21/23 
  Verifying  : boost-1.53.0-28.el7.x86_64                                                                                                                           22/23 
  Verifying  : boost-filesystem-1.53.0-28.el7.x86_64                                                                                                                23/23 

Installed:
  boost-devel.x86_64 0:1.53.0-28.el7                                                                                                                                      

Dependency Installed:
  boost.x86_64 0:1.53.0-28.el7            boost-atomic.x86_64 0:1.53.0-28.el7      boost-chrono.x86_64 0:1.53.0-28.el7           boost-context.x86_64 0:1.53.0-28.el7   
  boost-date-time.x86_64 0:1.53.0-28.el7  boost-filesystem.x86_64 0:1.53.0-28.el7  boost-graph.x86_64 0:1.53.0-28.el7            boost-iostreams.x86_64 0:1.53.0-28.el7 
  boost-locale.x86_64 0:1.53.0-28.el7     boost-math.x86_64 0:1.53.0-28.el7        boost-program-options.x86_64 0:1.53.0-28.el7  boost-python.x86_64 0:1.53.0-28.el7    
  boost-random.x86_64 0:1.53.0-28.el7     boost-regex.x86_64 0:1.53.0-28.el7       boost-serialization.x86_64 0:1.53.0-28.el7    boost-signals.x86_64 0:1.53.0-28.el7   
  boost-system.x86_64 0:1.53.0-28.el7     boost-test.x86_64 0:1.53.0-28.el7        boost-thread.x86_64 0:1.53.0-28.el7           boost-timer.x86_64 0:1.53.0-28.el7     
  boost-wave.x86_64 0:1.53.0-28.el7       libicu.x86_64 0:50.2-4.el7_7            

Complete!
[root@localhost ~]# 
.....

通过YUM安装的Boost版本为1.53,目前官网的版本为1.85,接下来我们通过编译安装Boost1.85

卸载命令

yum remove boost-devel

效果如下:

[root@localhost ~]# yum remove boost-devel
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package boost-devel.x86_64 0:1.53.0-28.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================
 Package                                    Arch                                  Version                                      Repository                            Size
==========================================================================================================================================================================
Removing:
 boost-devel                                x86_64                                1.53.0-28.el7                                @base                                 85 M

Transaction Summary
==========================================================================================================================================================================
Remove  1 Package

Installed size: 85 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : boost-devel-1.53.0-28.el7.x86_64                                                                                                                       1/1 
  Verifying  : boost-devel-1.53.0-28.el7.x86_64                                                                                                                       1/1 

Removed:
  boost-devel.x86_64 0:1.53.0-28.el7                                                                                                                                      

Complete!
[root@localhost ~]# 

通过编译安装(官网最新版本1.85.0)

1.安装相关依赖

yum -y install gcc gcc-c++ python python-devel libicu libicu-devel zlib zlib-devel bzip2 bzip2-devel

效果如下:

[root@localhost ~]# yum -y install gcc gcc-c++ python python-devel libicu libicu-devel zlib zlib-devel bzip2 bzip2-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Package gcc-4.8.5-44.el7.x86_64 already installed and latest version
Package gcc-c++-4.8.5-44.el7.x86_64 already installed and latest version
Package python-2.7.5-94.el7_9.x86_64 already installed and latest version
Package libicu-50.2-4.el7_7.x86_64 already installed and latest version
Package zlib-1.2.7-21.el7_9.x86_64 already installed and latest version
Package zlib-devel-1.2.7-21.el7_9.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package bzip2.x86_64 0:1.0.6-13.el7 will be installed
---> Package bzip2-devel.x86_64 0:1.0.6-13.el7 will be installed
---> Package libicu-devel.x86_64 0:50.2-4.el7_7 will be installed
---> Package python-devel.x86_64 0:2.7.5-94.el7_9 will be installed
--> Processing Dependency: python2-rpm-macros > 3-30 for package: python-devel-2.7.5-94.el7_9.x86_64
--> Processing Dependency: python-rpm-macros > 3-30 for package: python-devel-2.7.5-94.el7_9.x86_64
--> Running transaction check
---> Package python-rpm-macros.noarch 0:3-34.el7 will be installed
--> Processing Dependency: python-srpm-macros for package: python-rpm-macros-3-34.el7.noarch
---> Package python2-rpm-macros.noarch 0:3-34.el7 will be installed
--> Running transaction check
---> Package python-srpm-macros.noarch 0:3-34.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================
 Package                                        Arch                               Version                                      Repository                           Size
==========================================================================================================================================================================
Installing:
 bzip2                                          x86_64                             1.0.6-13.el7                                 base                                 52 k
 bzip2-devel                                    x86_64                             1.0.6-13.el7                                 base                                218 k
 libicu-devel                                   x86_64                             50.2-4.el7_7                                 base                                703 k
 python-devel                                   x86_64                             2.7.5-94.el7_9                               updates                             399 k
Installing for dependencies:
 python-rpm-macros                              noarch                             3-34.el7                                     base                                9.1 k
 python-srpm-macros                             noarch                             3-34.el7                                     base                                8.8 k
 python2-rpm-macros                             noarch                             3-34.el7                                     base                                8.1 k

Transaction Summary
==========================================================================================================================================================================
Install  4 Packages (+3 Dependent packages)

Total download size: 1.4 M
Installed size: 5.4 M
Downloading packages:
(1/7): bzip2-1.0.6-13.el7.x86_64.rpm                                                                                                               |  52 kB  00:00:00     
(2/7): python-srpm-macros-3-34.el7.noarch.rpm                                                                                                      | 8.8 kB  00:00:00     
(3/7): python-rpm-macros-3-34.el7.noarch.rpm                                                                                                       | 9.1 kB  00:00:00     
(4/7): python2-rpm-macros-3-34.el7.noarch.rpm                                                                                                      | 8.1 kB  00:00:00     
(5/7): bzip2-devel-1.0.6-13.el7.x86_64.rpm                                                                                                         | 218 kB  00:00:00     
(6/7): python-devel-2.7.5-94.el7_9.x86_64.rpm                                                                                                      | 399 kB  00:00:00     
(7/7): libicu-devel-50.2-4.el7_7.x86_64.rpm                                                                                                        | 703 kB  00:00:01     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                     999 kB/s | 1.4 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-srpm-macros-3-34.el7.noarch                                                                                                                     1/7 
  Installing : python-rpm-macros-3-34.el7.noarch                                                                                                                      2/7 
  Installing : python2-rpm-macros-3-34.el7.noarch                                                                                                                     3/7 
  Installing : python-devel-2.7.5-94.el7_9.x86_64                                                                                                                     4/7 
  Installing : libicu-devel-50.2-4.el7_7.x86_64                                                                                                                       5/7 
  Installing : bzip2-1.0.6-13.el7.x86_64                                                                                                                              6/7 
  Installing : bzip2-devel-1.0.6-13.el7.x86_64                                                                                                                        7/7 
  Verifying  : bzip2-devel-1.0.6-13.el7.x86_64                                                                                                                        1/7 
  Verifying  : python2-rpm-macros-3-34.el7.noarch                                                                                                                     2/7 
  Verifying  : bzip2-1.0.6-13.el7.x86_64                                                                                                                              3/7 
  Verifying  : python-rpm-macros-3-34.el7.noarch                                                                                                                      4/7 
  Verifying  : libicu-devel-50.2-4.el7_7.x86_64                                                                                                                       5/7 
  Verifying  : python-srpm-macros-3-34.el7.noarch                                                                                                                     6/7 
  Verifying  : python-devel-2.7.5-94.el7_9.x86_64                                                                                                                     7/7 

Installed:
  bzip2.x86_64 0:1.0.6-13.el7         bzip2-devel.x86_64 0:1.0.6-13.el7         libicu-devel.x86_64 0:50.2-4.el7_7         python-devel.x86_64 0:2.7.5-94.el7_9        

Dependency Installed:
  python-rpm-macros.noarch 0:3-34.el7                    python-srpm-macros.noarch 0:3-34.el7                    python2-rpm-macros.noarch 0:3-34.el7                   

Complete!
[root@localhost ~]# 

2.查询官网下载最新安装包并解压

boost官网地址:https://www.boost.org/
在这里插入图片描述
执行命令如下

cd /usr/local
wget https://boostorg.jfrog.io/artifactory/main/release/1.85.0/source/boost_1_85_0.tar.gz
tar -xzvf boost_1_85_0.tar.gz
cd boost_1_85_0

3.编译Boost

./bootstrap.sh
./b2

效果如下:

[root@localhost boost_1_85_0]# ./bootstrap.sh
Building B2 engine..

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

g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 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 -pthread -O2 -s -DNDEBUG bindjam.cpp builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filent.cpp filesys.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 option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp startup.cpp tasks.cpp timestamp.cpp value.cpp variable.cpp w32_getreg.cpp mod_jam_builtin.cpp mod_jam_class.cpp mod_jam_errors.cpp mod_jam_modules.cpp mod_order.cpp mod_path.cpp mod_property_set.cpp mod_regex.cpp mod_sequence.cpp mod_set.cpp mod_string.cpp mod_summary.cpp mod_sysinfo.cpp mod_version.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

The configuration generated uses gcc to build by default. If that is
unintended either use the --with-toolset option or adjust configuration, by
editing 'project-config.jam'.

Further information:

   - Command line help:
     ./b2 --help
     
   - Getting started guide: 
     http://www.boost.org/more/getting_started/unix-variants.html
     
   - B2 documentation:
     http://www.boost.org/build/

[root@localhost boost_1_85_0]# ./b2
Performing configuration checks

    - default address-model    : 64-bit [1]
    - default architecture     : x86 [1]

Building the Boost C++ Libraries.


    - compiler supports SSE2   : yes [2]
    - compiler supports SSE4.1 : yes [2]
    - cxx11_static_assert      : no [2]
    - compiler supports SSE2   : yes [3]
    - compiler supports SSE4.1 : yes [3]
    - cxx11_static_assert      : no [3]
    - cxx11_variadic_templates : no [2]
    - cxx11_variadic_templates : no [3]
    - cxx11_hdr_ratio          : no [2]
    - cxx11_hdr_ratio          : no [3]
    - cxx20_hdr_concepts       : no [2]
    - cxx20_hdr_concepts       : no [3]
    - has std::atomic_ref      : no [2]
    - has -Wl,--no-undefined   : yes [2]
    - has statx                : no [2]
    - has statx syscall        : no [2]
    - cxx11_rvalue_references  : no [2]
    - has std::atomic_ref      : no [3]
    - has -Wl,--no-undefined   : yes [3]
    - has statx                : no [3]
    - has statx syscall        : no [3]
    - cxx11_rvalue_references  : no [3]
    - cxx11_auto_declarations  : no [2]
    - cxx11_auto_declarations  : no [3]
    - 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]
    - has fallocate            : yes [2]
    - 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]
    - icu                      : yes [2]
    - iconv (libc)             : yes [2]
    - icu                      : yes [3]
    - iconv (libc)             : yes [3]
    - native atomic int32 supported : no [2]
    - native syslog supported  : yes [2]
    - pthread supports robust mutexes : yes [2]
    - Boost.Regex is header-only : no [2]
    - lockfree boost::atomic_flag : no [2]
    - compiler supports SSSE3  : yes [2]
    - compiler supports AVX2   : yes [2]
    - compiler supports SSSE3  : yes [3]
    - compiler supports AVX2   : yes [3]
    - native atomic int32 supported : no [3]
    - native syslog supported  : yes [3]
    - pthread supports robust mutexes : yes [3]
    - cxx11_lambdas            : no [2]
    - cxx11_lambdas            : no [3]
    - gcc visibility           : yes [2]
    - cxx11_noexcept           : no [2]
    - gcc visibility           : yes [3]
    - cxx11_noexcept           : no [3]
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
    - std_wstreambuf builds    : yes [2]
    - std_wstreambuf           : yes [2]
    - BOOST_COMP_GNUC >= 4.3.0 : no [2]
    - BOOST_COMP_GNUC >= 4.3.0 : no [4]
    - compiler supports SSE2   : yes [4]
    - compiler supports SSE4.1 : yes [4]
    - cxx11_static_assert      : no [4]
    - compiler supports SSE2   : yes [5]
    - compiler supports SSE4.1 : yes [5]
    - cxx11_static_assert      : no [5]
    - cxx11_variadic_templates : no [4]
    - cxx11_variadic_templates : no [5]
    - cxx11_hdr_ratio          : no [4]
    - cxx11_hdr_ratio          : no [5]
    - cxx20_hdr_concepts       : no [4]
    - cxx20_hdr_concepts       : no [5]
    - has std::atomic_ref      : no [4]
    - has statx                : no [4]
    - has statx syscall        : no [4]
    - cxx11_rvalue_references  : no [4]
    - has std::atomic_ref      : no [5]
    - has statx                : no [5]
    - has statx syscall        : no [5]
    - cxx11_rvalue_references  : no [5]
    - cxx11_auto_declarations  : no [4]
    - cxx11_auto_declarations  : no [5]
    - has init_priority attribute : yes [4]
    - has stat::st_blksize     : yes [4]
    - has stat::st_mtim        : yes [4]
    - has stat::st_mtimensec   : no [4]
    - has stat::st_mtimespec   : no [4]
    - has stat::st_birthtim    : no [4]
    - has stat::st_birthtimensec : no [4]
    - has stat::st_birthtimespec : no [4]
    - has fdopendir(O_NOFOLLOW) : yes [4]
    - has dirent::d_type       : yes [4]
    - has POSIX *at APIs       : yes [4]
    - has fallocate            : yes [4]
    - has_icu builds           : yes [4]
....
gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/link-static/threading-multi/visibility-hidden/xml_report_formatter.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/compiler_log_formatter.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/cpp_main.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/debug.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/decorator.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/execution_monitor.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/framework.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/junit_log_formatter.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/plain_report_formatter.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/progress_monitor.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/results_collector.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/results_reporter.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/test_tools.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/test_tree.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/unit_test_log.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/unit_test_main.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/unit_test_monitor.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/unit_test_parameters.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/xml_log_formatter.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/xml_report_formatter.o
[root@localhost boost_1_85_0]# 

这将编译并安装Boost库到默认的系统路径,如/usr/local/include和/usr/local/lib。如果你需要特定的编译选项或者库的子集,你可以在运行./bootstrap.sh时添加参数,例如,只编译线程库和系统库:

./bootstrap.sh --with-libraries=system,thread
./b2

4.安装Boost库到系统路径

sudo ./b2 install

效果如下:

    - default address-model    : 64-bit (cached) [1]
    - default architecture     : x86 (cached) [1]
    - compiler supports SSE2   : yes (cached) [2]
    - compiler supports SSE4.1 : yes (cached) [2]
    - cxx11_static_assert      : no  (cached) [2]
    - compiler supports SSE2   : yes (cached) [3]
    - compiler supports SSE4.1 : yes (cached) [3]
    - cxx11_static_assert      : no  (cached) [3]
    - cxx11_variadic_templates : no  (cached) [2]
    - cxx11_variadic_templates : no  (cached) [3]
    - cxx11_hdr_ratio          : no  (cached) [2]
    - cxx11_hdr_ratio          : no  (cached) [3]
    - cxx20_hdr_concepts       : no  (cached) [2]
    - cxx20_hdr_concepts       : no  (cached) [3]
    - has std::atomic_ref      : no  (cached) [2]
    - has -Wl,--no-undefined   : yes (cached) [2]
    - has statx                : no  (cached) [2]
    - has statx syscall        : no  (cached) [2]
    - cxx11_rvalue_references  : no  (cached) [2]
    - has std::atomic_ref      : no  (cached) [3]
    - has -Wl,--no-undefined   : yes (cached) [3]
    - has statx                : no  (cached) [3]
    - has statx syscall        : no  (cached) [3]
    - cxx11_rvalue_references  : no  (cached) [3]
    - cxx11_auto_declarations  : no  (cached) [2]
    - cxx11_auto_declarations  : no  (cached) [3]
    - has init_priority attribute : yes (cached) [2]
    - has stat::st_blksize     : yes (cached) [2]
    - has stat::st_mtim        : yes (cached) [2]
    - has stat::st_mtimensec   : no  (cached) [2]
    - has stat::st_mtimespec   : no  (cached) [2]
    - has stat::st_birthtim    : no  (cached) [2]
    - has stat::st_birthtimensec : no  (cached) [2]
    - has stat::st_birthtimespec : no  (cached) [2]
    - has fdopendir(O_NOFOLLOW) : yes (cached) [2]
    - has dirent::d_type       : yes (cached) [2]
    - has POSIX *at APIs       : yes (cached) [2]
    - has fallocate            : yes (cached) [2]
    - has_icu builds           : yes (cached) [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 (cached)
    - bzip2                    : yes (cached)
    - lzma                     : no  (cached)
    - zstd                     : no  (cached)
    - has_lzma_cputhreads builds : no  (cached) [2]
    - cxx11_constexpr          : no  (cached) [2]
    - cxx11_constexpr          : no  (cached) [3]
    - icu                      : yes (cached) [2]
    - iconv (libc)             : yes (cached) [2]
    - icu                      : yes (cached) [3]
    - iconv (libc)             : yes (cached) [3]
    - native atomic int32 supported : no  (cached) [2]
    - native syslog supported  : yes (cached) [2]
    - pthread supports robust mutexes : yes (cached) [2]
    - Boost.Regex is header-only : no  (cached) [2]
    - lockfree boost::atomic_flag : no  (cached) [2]
    - compiler supports SSSE3  : yes (cached) [2]
    - compiler supports AVX2   : yes (cached) [2]
    - compiler supports SSSE3  : yes (cached) [3]
    - compiler supports AVX2   : yes (cached) [3]
    - native atomic int32 supported : no  (cached) [3]
    - native syslog supported  : yes (cached) [3]
    - pthread supports robust mutexes : yes (cached) [3]
    - cxx11_lambdas            : no  (cached) [2]
    - cxx11_lambdas            : no  (cached) [3]
    - gcc visibility           : yes (cached) [2]
    - cxx11_noexcept           : no  (cached) [2]
    - gcc visibility           : yes (cached) [3]
    - cxx11_noexcept           : no  (cached) [3]
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
    - std_wstreambuf builds    : yes (cached) [2]
....
 gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/plain_report_formatter.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/progress_monitor.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/results_collector.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/results_reporter.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/test_tools.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/test_tree.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/unit_test_log.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/unit_test_main.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/unit_test_monitor.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/unit_test_parameters.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/xml_log_formatter.o
   gcc.compile.c++ bin.v2/libs/test/build/gcc-4.8/release/threading-multi/visibility-hidden/xml_report_formatter.o
[root@localhost boost_1_85_0]# 

Boost库验证

示例代码:

#include <boost/filesystem.hpp>
#include <iostream>

int main(int argc, char* argv[])
{
    if (argc < 2){
        std::cout << "Usage: " << argv[0] << " path\n";
        return 1;
    }

    boost::filesystem::path p(argv[1]);

    if (boost::filesystem::exists(p)) {
        if (boost::filesystem::is_directory(p))
            std::cout << p << " is a directory.\n";
        else if (boost::filesystem::is_regular_file(p))
            std::cout << p << " is a regular file.\n";
        else
            std::cout << p << " exists but is not a directory or regular file.\n";
    } else {
        std::cout << p << " does not exist.\n";
    }

    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.28)
project(boost_example)
set(BOOST_ROOT "/usr/include")
set(Boost_INCLUDE_DIR "/usr/include")
set(Boost_SYSTEM_LIBRARY "/usr/include/boost/stage/lib")

set(CMAKE_CXX_STANDARD 20)
set(boostlib filesystem program_options regex)
#
find_package(Boost REQUIRED COMPONENTS ${boostlib})

add_executable(boost_example main.cpp)
if(Boost_FOUND)
    message(STATUS "Boost version found")
    message(STATUS " Boost libraries:${Boost_LIBRARIES}")
    target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
else()
    message(STATUS "Boost version not found")
endif()

在这里插入图片描述

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

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

相关文章

7-4 是否同一棵二叉搜索树

7-4 是否同一棵二叉搜索树&#xff08;25分&#xff09; 题目描述 给定一个插入序列就可以唯一确定一棵二叉搜索树。然而&#xff0c;一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列 {2, 1, 3} 和 {2, 3, 1} 插入初始为空的二叉搜索树&#xff0c;都得…

计算机毕业设计 | vue+springboot汽车销售管理系统(附源码)

1&#xff0c;项目介绍 本项目基于spring boot以及Vue开发&#xff0c;前端实现基于PanJiaChen所提供的开源后台项目vue-element-admin改造。 针对汽车销售提供客户信息、车辆信息、订单信息、销售人员管理、财务报表等功能&#xff0c;提供经理和销售两种角色进行管理。 2&…

程控负载的功能实现原理

程控负载&#xff0c;顾名思义&#xff0c;就是可以通过程序控制其工作状态的负载设备。它的主要功能是模拟实际负载的工作状态&#xff0c;为电源、电子设备等提供稳定的工作电流或电压。程控负载的功能实现原理主要包括以下几个方面&#xff1a; 1. 电流和电压调节&#xff1…

什么是短信群发上行和下行

短信群发是一种广泛应用于商业和个人通信的技术&#xff0c;通过一次多条的方式&#xff0c;可以快速高效地传递信息。在实际的群发过程中&#xff0c;会涉及到上行和下行的概念。本文将详细介绍什么是短信群发上行和下行&#xff0c;并解释它们的应用。 什么是短信群发上行 群…

JS-拖拽位移、放大缩小

对同一盒子拖拽位移、缩放&#xff0c;这其实是不符合js的逻辑的&#xff0c;位移和拖拽必然会互相影响&#xff0c;所以需要在布局上略加调整 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>Title…

【python量化交易】qteasy使用教程05——创建第一个自定义交易策略

创建第一个自定义交易策略 使用qteasy创建自定义交易策略开始前的准备工作本节的目标自定义策略的实现方法使用 qteasy 的 Strategy 策略类三种不同的自定义策略基类定义一个双均线择时交易策略定义策略运行时机定义策略需要的数据自定义交易策略的实现&#xff1a;realize()获…

短信清空了!华为手机短信删除了怎么恢复?

“有没有人知道这是怎么回事呀&#xff0c;原先有一千多条未读一直放着没管&#xff0c;昨天根本没打开短信这个软件&#xff0c;今晚突然发现只剩一条了&#xff0c;是华为手机自动清理了吗&#xff01;到底该怎么恢复呀&#xff1f;我真崩溃&#xff01;” 在日常生活中&…

(✌)粤嵌—2024/5/9—寻找两个正序数组的中位数

代码实现&#xff1a; int binary_search(int *arr, int n, int key) {int head 0, tail n - 1, mid;while (head < tail) {mid (head tail) / 2;if (arr[mid] key) {return mid;}if (arr[mid] > key) {tail mid - 1;} else {head mid 1;}}return head; }void in…

Spring Boot | Spring Boot 整合 “异步任务“ 的实现

目录&#xff1a; 一、异步任务1.1 "无返回值" 异步任务调用 :① 创建项目② 编写 "异步调用方法" ( 使用 Async 注解 )③ "主程序启动类"中 开启基于 "注解" 的异步任务支持 ( 使用EnableAsync注解 )④ 编写 "控制层" 相关…

Vue中常用指令

Vue中的常用指令 Vue中的常用指令内容渲染指令条件渲染指令事件绑定指令内联语句事件处理函数给事件处理函数传参 属性绑定指令列表渲染指令v-for中的key 双向绑定指令 Vue中的常用指令 概念&#xff1a;指令 是 Vue 提供的带有 v- 前缀 的 特殊 标签属性。Vue 会根据不同的【…

2024年数维杯高校数学建模竞赛(B题) 建模解析| 生物质和煤共热解问题的研究 |小鹿学长带队指引全代码文章与思路

我是鹿鹿学长&#xff0c;就读于上海交通大学&#xff0c;截至目前已经帮200人完成了建模与思路的构建的处理了&#xff5e; 本篇文章是鹿鹿学长经过深度思考&#xff0c;独辟蹊径&#xff0c;实现综合建模。独创复杂系统视角&#xff0c;帮助你解决数维杯的难关呀。 完整内容可…

Linux-远程登录

远程登录Linux服务器的两款小工具&#xff1a; 1、Xshell &#xff08;可以远程登录到Linux终端控制台&#xff09; 2、 Xftp (可以与Linux服务器互相传递文件) 家庭/学校免费 - NetSarang Website 下载地址 1、傻瓜式安装Xshell6 2、在Linux主机上查看 Linux主机的…

Java Web 学习笔记(一) —— MySQL(3)

目录 1 Mysql 函数1.1 日期函数1.2 判断函数1.3 字符函数1.4 数学函数 2 Mysql 性能2.1 提高操作数据库性能2.2 执行次数比较多的语句2.3 sql语句的执行效率 3 Mysql 优化&#xff08;***&#xff09;3.1 定位慢查询3.2 SQL执行计划3.3 索引3.3.1 索引介绍与分类3.3.2 索引的使…

案例研究|硬之城借助DataEase以数据驱动供应链精细化管理

深圳硬之城信息技术有限公司&#xff08;以下简称为“硬之城”&#xff09;成立于2015年&#xff0c;专注电子元件供应链领域&#xff0c;定位于电子产业供应链与智造平台。硬之城通过名为“Allchips”的集成式服务平台&#xff0c;为客户提供一站式的电子元件采购和供应链管理…

VLAN聚合

VLAN聚合&#xff08;VLAN Aggregation&#xff0c;也称Super VLAN&#xff09;指在一个物理网络内&#xff0c;用多个VLAN&#xff08;称为Sub-VLAN&#xff09;隔离广播域&#xff0c;并将这些Sub-VLAN聚合成一个逻辑的VLAN&#xff08;称为Super-VLAN&#xff09;&#xff0…

MySQL·复合查询

目录 基本查询回顾 案例1&#xff1a;查询工资高于500或岗位为MANAGER的雇员&#xff0c;同时还要满足他们的姓名首字母为大写的J 案例2&#xff1a;按照部门号升序而雇员的工资降序排序 案例3&#xff1a;使用年薪进行降序排序 案例4&#xff1a;显示工资最高的员工的名字…

『先进技术助力』Kompas AI:智能AI代理在工作中的应用与效率提升

『智能化未来』Kompas AI如何改变我们的工作方式&#xff1f; 在这个信息时代&#xff0c;利用AI聊天机器人来处理机械性的工作已经成为一种趋势。ChatGPT作为一种智能助手&#xff0c;不仅能够提高工作效率&#xff0c;还可以帮助我们更明智地做出决策&#xff0c;从而释放出更…

【MySQL数据库】丨一文详解 JdbcTemplate(Spring中的CRUD)

前言 JdbcTemplate 是 Spring框架 中提供的一个对象&#xff0c;用于简化JDBC操作。它使得数据库操作变得更为简单和方便&#xff0c;大大提高了开发效率。 文章目录 前言为何要使用JdbcTemplate在JdbcTemplate中执行SQL语句的方法大致分为3类&#xff1a;案例代码 JdbcTemplat…

活字格中如何加入JavaScript的代码和事件以及如何调试

活字格&#xff1a; 如何加入JavaScript的代码和事件 1&#xff09;选中组件。 2&#xff09;编辑命令“按钮。 3&#xff09;选择JavaScript命令&#xff0c;并点亮五星。 4&#xff09;编写js代码&#xff0c;确定。 5&#xff09;运行。 如何查看js运行&#xff1a; …

【R语言】边缘概率密度图

边缘概率密度图是一种在多变量数据分析中常用的图形工具&#xff0c;用于显示每个单独变量的概率密度估计。它通常用于散点图的边缘&#xff0c;以便更好地理解单个变量的分布情况&#xff0c;同时保留了散点图的相关性信息。 在边缘概率密度图中&#xff0c;每个变量的概率密度…