【gcc】centos安装gcc

本文说的方法是通过centos自带的包管理工具安装gcc,非离线安装,离线安装可以百度搜索到有方法,这个需要对应下载指定版本的gcc。

1.确认下系统是否安装了yum,这个一般云服务器都会自带安装。

2.再就是SCL管理工具,可以直接运行一下命令安装

yum install -y centos-release-scl centos-release-scl-rh

3.就是查看下自己的yum源,可能需要改为国内镜像,比如阿里,清华或者腾讯的,我们用的是腾讯的云服务器,他默认将镜像源改成了腾讯的。查看方法:

vi /etc/yum.repos.d/CentOS-Base.repo

看下源是不是国内的。

4.搜下有没有自己需要版本的包,gcc是包含在devtoolset包里的:

[root@VM_16_13_centos devtoolset-9]# yum search "devtoolset"
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.aliyun.com
 * centos-sclo-sclo: mirrors.ustc.edu.cn
======================================================================================================= N/S matched: devtoolset =======================================================================================================
devtoolset-10.x86_64 : Package that installs devtoolset-10
devtoolset-10-runtime.x86_64 : Package that handles devtoolset-10 Software Collection.
devtoolset-11.x86_64 : Package that installs devtoolset-11
devtoolset-11-runtime.x86_64 : Package that handles devtoolset-11 Software Collection.
devtoolset-7.x86_64 : Package that installs devtoolset-7
devtoolset-7-runtime.x86_64 : Package that handles devtoolset-7 Software Collection.
devtoolset-8.x86_64 : Package that installs devtoolset-8
devtoolset-8-runtime.x86_64 : Package that handles devtoolset-8 Software Collection.
devtoolset-9.x86_64 : Package that installs devtoolset-9
devtoolset-9-runtime.x86_64 : Package that handles devtoolset-9 Software Collection.
devtoolset-10-annobin.x86_64 : Annotate and examine compiled binary files
devtoolset-10-annobin-annocheck.x86_64 : A tool for checking the security hardening status of binaries
devtoolset-10-binutils.x86_64 : A GNU collection of binary utilities
devtoolset-10-binutils-devel.x86_64 : BFD and opcodes static and dynamic libraries and header files
devtoolset-10-build.x86_64 : Package shipping basic build configuration
devtoolset-10-dwz.x86_64 : DWARF optimization and duplicate removal tool
devtoolset-10-dyninst.x86_64 : An API for Run-time Code Generation
devtoolset-10-dyninst-devel.x86_64 : Header files for compiling programs with Dyninst
devtoolset-10-dyninst-doc.x86_64 : Documentation for using the Dyninst API
devtoolset-10-dyninst-static.x86_64 : Static libraries for the compiling programs with Dyninst
devtoolset-10-dyninst-testsuite.x86_64 : Programs for testing Dyninst
devtoolset-10-elfutils.x86_64 : A collectio2 of utilities and DSOs to handle ELF files and DWARF data
devtoolset-10-elfutils-debuginfod.x86_64 : HTTP ELF/DWARF file server addressed by build-id
devtoolset-10-elfutils-debuginfod-client.x86_64 : Library and command line client for build-id HTTP ELF/DWARF server
devtoolset-10-elfutils-debuginfod-client-devel.x86_64 : Libraries and headers to build debuginfod client applications
devtoolset-10-elfutils-devel.x86_64 : Development libraries to handle compiled objects
devtoolset-10-elfutils-libelf.x86_64 : Library to read and write ELF files
devtoolset-10-elfutils-libelf-devel.x86_64 : Development support for libelf
devtoolset-10-elfutils-libs.x86_64 : Libraries to handle compiled objects
devtoolset-10-gcc.x86_64 : GCC version 10
devtoolset-10-gcc-c++.x86_64 : C++ support for GCC  version 10
devtoolset-10-gcc-gdb-plugin.x86_64 : GCC 10 plugin for GDB
devtoolset-10-gcc-gfortran.x86_64 : Fortran support for GCC 10
devtoolset-10-gcc-plugin-devel.x86_64 : Support for compiling GCC plugins
devtoolset-10-gdb.x86_64 : A GNU source-level debugger for C, C++, Fortran, Go and other languages
devtoolset-10-gdb-doc.noarch : Documentation for GDB (the GNU source-level debugger)
devtoolset-10-gdb-gdbserver.x86_64 : A standalone server for GDB (the GNU source-level debugger)
devtoolset-10-libasan-devel.x86_64 : The Address Sanitizer static library
devtoolset-10-libatomic-devel.x86_64 : The GNU Atomic static library
devtoolset-10-libgccjit.x86_64 : Library for embedding GCC inside programs and libraries
devtoolset-10-libgccjit-devel.x86_64 : Support for embedding GCC inside programs and libraries
devtoolset-10-libgccjit-docs.x86_64 : Documentation for embedding GCC inside programs and libraries
devtoolset-10-libitm-devel.x86_64 : The GNU Transactional Memory support
devtoolset-10-liblsan-devel.x86_64 : The Leak Sanitizer static library
devtoolset-10-libquadmath-devel.x86_64 : GCC 10 __float128 support
devtoolset-10-libstdc++-devel.x86_64 : Header files and libraries for C++ development
devtoolset-10-libstdc++-docs.x86_64 : Documentation for the GNU standard C++ library
devtoolset-10-libtsan-devel.x86_64 : The Thread Sanitizer static library
devtoolset-10-libubsan-devel.x86_64 : The Undefined Behavior Sanitizer static library
devtoolset-10-ltrace.x86_64 : Tracks runtime library calls from dynamically linked executables
devtoolset-10-make.x86_64 : A GNU tool which simplifies the build process for users
devtoolset-10-make-devel.x86_64 : Header file for externally visible definitions
devtoolset-10-memstomp.x86_64 : Warns of memory argument overlaps to various functions
devtoolset-10-oprofile.x86_64 : System wide profiler
devtoolset-10-oprofile-devel.x86_64 : Header files and libraries for developing apps which will use oprofile
devtoolset-10-oprofile-jit.x86_64 : Libraries required for profiling Java and other JITed code
devtoolset-10-perftools.x86_64 : Package shipping performance tools
devtoolset-10-strace.x86_64 : Tracks and displays system calls associated with a running process
devtoolset-10-systemtap.x86_64 : Programmable system-wide instrumentation system
devtoolset-10-systemtap-client.x86_64 : Programmable system-wide instrumentation system - client
devtoolset-10-systemtap-devel.x86_64 : Programmable system-wide instrumentation system - development headers, tools
devtoolset-10-systemtap-initscript.x86_64 : Systemtap Initscripts
devtoolset-10-systemtap-runtime.x86_64 : Programmable system-wide instrumentation system - runtime
devtoolset-10-systemtap-runtime-python2.x86_64 : Systemtap Python 2 Runtime Support
devtoolset-10-systemtap-sdt-devel.x86_64 : Static probe support tools
devtoolset-10-systemtap-server.x86_64 : Instrumentation System Server
devtoolset-10-systemtap-testsuite.x86_64 : Instrumentation System Testsuite
devtoolset-10-toolchain.x86_64 : Package shipping basic toolchain applications
devtoolset-10-valgrind.x86_64 : Tool for finding memory management bugs in programs
devtoolset-10-valgrind-devel.x86_64 : Development files for valgrind aware programs
devtoolset-11-annobin-annocheck.x86_64 : A tool for checking the security hardening status of binaries
devtoolset-11-annobin-docs.noarch : Documentation and shell scripts for use with annobin
devtoolset-11-annobin-plugin-gcc.x86_64 : annobin gcc plugin
devtoolset-11-binutils.x86_64 : A GNU collection of binary utilities
devtoolset-11-binutils-devel.x86_64 : BFD and opcodes static and dynamic libraries and header files
devtoolset-11-build.x86_64 : Package shipping basic build configuration
devtoolset-11-dwz.x86_64 : DWARF optimization and duplicate removal tool
devtoolset-11-dyninst.x86_64 : An API for Run-time Code Generation
devtoolset-11-dyninst-devel.x86_64 : Header files for compiling programs with Dyninst
devtoolset-11-dyninst-doc.x86_64 : Documentation for using the Dyninst API
devtoolset-11-dyninst-static.x86_64 : Static libraries for the compiling programs with Dyninst
devtoolset-11-dyninst-testsuite.x86_64 : Programs for testing Dyninst
devtoolset-11-elfutils.x86_64 : A collection of utilities and DSOs to handle ELF files and DWARF data
devtoolset-11-elfutils-debuginfod.x86_64 : HTTP ELF/DWARF file server addressed by build-id
devtoolset-11-elfutils-debuginfod-client.x86_64 : Library and command line client for build-id HTTP ELF/DWARF server
devtoolset-11-elfutils-debuginfod-client-devel.x86_64 : Libraries and headers to build debuginfod client applications
devtoolset-11-elfutils-devel.x86_64 : Development libraries to handle compiled objects
devtoolset-11-elfutils-libelf.x86_64 : Library to read and write ELF files
devtoolset-11-elfutils-libelf-devel.x86_64 : Development support for libelf
devtoolset-11-elfutils-libs.x86_64 : Libraries to handle compiled objects
devtoolset-11-gcc.x86_64 : GCC version 11
devtoolset-11-gcc-c++.x86_64 : C++ support for GCC  version 11
devtoolset-11-gcc-gdb-plugin.x86_64 : GCC 11 plugin for GDB
devtoolset-11-gcc-gfortran.x86_64 : Fortran support for GCC 11
devtoolset-11-gcc-plugin-devel.x86_64 : Support for compiling GCC plugins
devtoolset-11-gdb.x86_64 : A GNU source-level debugger for C, C++, Fortran, Go and other languages
devtoolset-11-gdb-doc.noarch : Documentation for GDB (the GNU source-level debugger)
devtoolset-11-gdb-gdbserver.x86_64 : A standalone server for GDB (the GNU source-level debugger)
devtoolset-11-libasan-devel.x86_64 : The Address Sanitizer static library
devtoolset-11-libatomic-devel.x86_64 : The GNU Atomic static library
devtoolset-11-libgccjit.x86_64 : Library for embedding GCC inside programs and libraries
devtoolset-11-libgccjit-devel.x86_64 : Support for embedding GCC inside programs and libraries
devtoolset-11-libgccjit-docs.x86_64 : Documentation for embedding GCC inside programs and libraries
devtoolset-11-libitm-devel.x86_64 : The GNU Transactional Memory support
devtoolset-11-liblsan-devel.x86_64 : The Leak Sanitizer static library
devtoolset-11-libquadmath-devel.x86_64 : GCC 11 __float128 support
devtoolset-11-libstdc++-devel.x86_64 : Header files and libraries for C++ development
devtoolset-11-libstdc++-docs.x86_64 : Documentation for the GNU standard C++ library
devtoolset-11-libtsan-devel.x86_64 : The Thread Sanitizer static library
devtoolset-11-libubsan-devel.x86_64 : The Undefined Behavior Sanitizer static library
devtoolset-11-ltrace.x86_64 : Tracks runtime library calls from dynamically linked executables
devtoolset-11-make.x86_64 : A GNU tool which simplifies the build process for users
devtoolset-11-make-devel.x86_64 : Header file for externally visible definitions
devtoolset-11-memstomp.x86_64 : Warns of memory argument overlaps to various functions
devtoolset-11-oprofile.x86_64 : System wide profiler
devtoolset-11-oprofile-devel.x86_64 : Header files and libraries for developing apps which will use oprofile
devtoolset-11-oprofile-jit.x86_64 : Libraries required for profiling Java and other JITed code
devtoolset-11-perftools.x86_64 : Package shipping performance tools
devtoolset-11-strace.x86_64 : Tracks and displays system calls associated with a running process
devtoolset-11-systemtap.x86_64 : Programmable system-wide instrumentation system
devtoolset-11-systemtap-client.x86_64 : Programmable system-wide instrumentation system - client
devtoolset-11-systemtap-devel.x86_64 : Programmable system-wide instrumentation system - development headers, tools
devtoolset-11-systemtap-initscript.x86_64 : Systemtap Initscripts
devtoolset-11-systemtap-runtime.x86_64 : Programmable system-wide instrumentation system - runtime
devtoolset-11-systemtap-sdt-devel.x86_64 : Static probe support tools
devtoolset-11-systemtap-server.x86_64 : Instrumentation System Server
devtoolset-11-systemtap-testsuite.x86_64 : Instrumentation System Testsuite
devtoolset-11-toolchain.x86_64 : Package shipping basic toolchain applications
devtoolset-11-valgrind.x86_64 : Tool for finding memory management bugs in programs
devtoolset-11-valgrind-devel.x86_64 : Development files for valgrind aware programs
devtoolset-7-all.x86_64 : Package shipping all available toolsets.
devtoolset-7-binutils.x86_64 : A GNU collection of binary utilities
devtoolset-7-binutils-devel.x86_64 : BFD and opcodes static and dynamic libraries and header files
devtoolset-7-build.x86_64 : Package shipping basic build configuration
devtoolset-7-dockerfiles.x86_64 : Package shipping Dockerfiles for Developer Toolset
devtoolset-7-dwz.x86_64 : DWARF optimization and duplicate removal tool
devtoolset-7-dyninst.x86_64 : An API for Run-time Code Generation
devtoolset-7-dyninst-devel.x86_64 : Header files for the compiling programs with Dyninst
devtoolset-7-dyninst-doc.x86_64 : Documentation for using the Dyninst API
devtoolset-7-dyninst-static.x86_64 : Static libraries for the compiling programs with Dyninst
devtoolset-7-dyninst-testsuite.x86_64 : Programs for testing Dyninst
devtoolset-7-elfutils.x86_64 : A collection of utilities and DSOs to handle ELF files and DWARF data
devtoolset-7-elfutils-devel.x86_64 : Development libraries to handle compiled objects
devtoolset-7-elfutils-libelf.x86_64 : Library to read and write ELF files
devtoolset-7-elfutils-libelf-devel.x86_64 : Development support for libelf
devtoolset-7-elfutils-libs.x86_64 : Libraries to handle compiled objects
devtoolset-7-gcc.x86_64 : GCC version 7
devtoolset-7-gcc-c++.x86_64 : C++ support for GCC version 7
devtoolset-7-gcc-gdb-plugin.x86_64 : GCC 7 plugin for GDB
devtoolset-7-gcc-gfortran.x86_64 : Fortran support for GCC 7
devtoolset-7-gcc-plugin-devel.x86_64 : Support for compiling GCC plugins
devtoolset-7-gdb.x86_64 : A GNU source-level debugger for C, C++, Fortran, Go and other languages
devtoolset-7-gdb-doc.noarch : Documentation for GDB (the GNU source-level debugger)
devtoolset-7-gdb-gdbserver.x86_64 : A standalone server for GDB (the GNU source-level debugger)
devtoolset-7-go.x86_64 : Package shipping the Go toolset
devtoolset-7-libasan-devel.x86_64 : The Address Sanitizer static library
devtoolset-7-libatomic-devel.x86_64 : The GNU Atomic static library
devtoolset-7-libcilkrts-devel.x86_64 : The Cilk+ static runtime library
devtoolset-7-libgccjit.x86_64 : Library for embedding GCC inside programs and libraries
devtoolset-7-libgccjit-devel.x86_64 : Support for embedding GCC inside programs and libraries
devtoolset-7-libgccjit-docs.x86_64 : Documentation for embedding GCC inside programs and libraries
devtoolset-7-libitm-devel.x86_64 : The GNU Transactional Memory support
devtoolset-7-liblsan-devel.x86_64 : The Leak Sanitizer static library
devtoolset-7-libmpx-devel.x86_64 : The Memory Protection Extensions static libraries
devtoolset-7-libquadmath-devel.x86_64 : GCC 7 __float128 support
devtoolset-7-libstdc++-devel.x86_64 : Header files and libraries for C++ development
devtoolset-7-libstdc++-docs.x86_64 : Documentation for the GNU standard C++ library
devtoolset-7-libtsan-devel.x86_64 : The Thread Sanitizer static library
devtoolset-7-libubsan-devel.x86_64 : The Undefined Behavior Sanitizer static library
devtoolset-7-llvm.x86_64 : Package shipping the LLVM toolset
devtoolset-7-ltrace.x86_64 : Tracks runtime library calls from dynamically linked executables
devtoolset-7-make.x86_64 : A GNU tool which simplifies the build process for users
devtoolset-7-memstomp.x86_64 : Warns of memory argument overlaps to various functions
devtoolset-7-oprofile.x86_64 : System wide profiler
devtoolset-7-oprofile-devel.x86_64 : Header files and libraries for developing apps which will use oprofile
devtoolset-7-oprofile-jit.x86_64 : Libraries required for profiling Java and other JITed code
devtoolset-7-perftools.x86_64 : Package shipping performance tools
devtoolset-7-rust.x86_64 : Package shipping the Rust toolset
devtoolset-7-strace.x86_64 : Tracks and displays system calls associated with a running process
devtoolset-7-systemtap.x86_64 : Programmable system-wide instrumentation system
devtoolset-7-systemtap-client.x86_64 : Programmable system-wide instrumentation system - client
devtoolset-7-systemtap-devel.x86_64 : Programmable system-wide instrumentation system - development headers, tools
devtoolset-7-systemtap-initscript.x86_64 : Systemtap Initscripts
devtoolset-7-systemtap-runtime.x86_64 : Programmable system-wide instrumentation system - runtime
devtoolset-7-systemtap-sdt-devel.x86_64 : Static probe support tools
devtoolset-7-systemtap-server.x86_64 : Instrumentation System Server
devtoolset-7-systemtap-testsuite.x86_64 : Instrumentation System Testsuite
devtoolset-7-toolchain.x86_64 : Package shipping basic toolchain applications
devtoolset-7-valgrind.x86_64 : Tool for finding memory management bugs in programs
devtoolset-7-valgrind-devel.x86_64 : Development files for valgrind
devtoolset-8-binutils.x86_64 : A GNU collection of binary utilities
devtoolset-8-binutils-devel.x86_64 : BFD and opcodes static and dynamic libraries and header files
devtoolset-8-build.x86_64 : Package shipping basic build configuration
devtoolset-8-dockerfiles.x86_64 : Package shipping Dockerfiles for Developer Toolset
devtoolset-8-dwz.x86_64 : DWARF optimization and duplicate removal tool
devtoolset-8-dyninst.x86_64 : An API for Run-time Code Generation
devtoolset-8-dyninst-devel.x86_64 : Header files for the compiling programs with Dyninst
devtoolset-8-dyninst-doc.x86_64 : Documentation for using the Dyninst API
devtoolset-8-dyninst-static.x86_64 : Static libraries for the compiling programs with Dyninst
devtoolset-8-dyninst-testsuite.x86_64 : Programs for testing Dyninst
devtoolset-8-elfutils.x86_64 : A collection of utilities and DSOs to handle ELF files and DWARF data
devtoolset-8-elfutils-devel.x86_64 : Development libraries to handle compiled objects
devtoolset-8-elfutils-libelf.x86_64 : Library to read and write ELF files
devtoolset-8-elfutils-libelf-devel.x86_64 : Development support for libelf
devtoolset-8-elfutils-libs.x86_64 : Libraries to handle compiled objects
devtoolset-8-gcc.x86_64 : GCC version 8
devtoolset-8-gcc-c++.x86_64 : C++ support for GCC version 8
devtoolset-8-gcc-gdb-plugin.x86_64 : GCC 8 plugin for GDB
devtoolset-8-gcc-gfortran.x86_64 : Fortran support for GCC 8
devtoolset-8-gcc-plugin-devel.x86_64 : Support for compiling GCC plugins
devtoolset-8-gdb.x86_64 : A GNU source-level debugger for C, C++, Fortran, Go and other languages
devtoolset-8-gdb-doc.noarch : Documentation for GDB (the GNU source-level debugger)
devtoolset-8-gdb-gdbserver.x86_64 : A standalone server for GDB (the GNU source-level debugger)
devtoolset-8-libasan-devel.x86_64 : The Address Sanitizer static library
devtoolset-8-libatomic-devel.x86_64 : The GNU Atomic static library
devtoolset-8-libgccjit.x86_64 : Library for embedding GCC inside programs and libraries
devtoolset-8-libgccjit-devel.x86_64 : Support for embedding GCC inside programs and libraries
devtoolset-8-libgccjit-docs.x86_64 : Documentation for embedding GCC inside programs and libraries
devtoolset-8-libitm-devel.x86_64 : The GNU Transactional Memory support
devtoolset-8-liblsan-devel.x86_64 : The Leak Sanitizer static library
devtoolset-8-libquadmath-devel.x86_64 : GCC 8 __float128 support
devtoolset-8-libstdc++-devel.x86_64 : Header files and libraries for C++ development
devtoolset-8-libstdc++-docs.x86_64 : Documentation for the GNU standard C++ library
devtoolset-8-libtsan-devel.x86_64 : The Thread Sanitizer static library
devtoolset-8-libubsan-devel.x86_64 : The Undefined Behavior Sanitizer static library
devtoolset-8-ltrace.x86_64 : Tracks runtime library calls from dynamically linked executables
devtoolset-8-make.x86_64 : A GNU tool which simplifies the build process for users
devtoolset-8-memstomp.x86_64 : Warns of memory argument overlaps to various functions
devtoolset-8-oprofile.x86_64 : System wide profiler
devtoolset-8-oprofile-devel.x86_64 : Header files and libraries for developing apps which will use oprofile
devtoolset-8-oprofile-jit.x86_64 : Libraries required for profiling Java and other JITed code
devtoolset-8-perftools.x86_64 : Package shipping performance tools
devtoolset-8-strace.x86_64 : Tracks and displays system calls associated with a running process
devtoolset-8-systemtap.x86_64 : Programmable system-wide instrumentation system
devtoolset-8-systemtap-client.x86_64 : Programmable system-wide instrumentation system - client
devtoolset-8-systemtap-devel.x86_64 : Programmable system-wide instrumentation system - development headers, tools
devtoolset-8-systemtap-initscript.x86_64 : Systemtap Initscripts
devtoolset-8-systemtap-runtime.x86_64 : Programmable system-wide instrumentation system - runtime
devtoolset-8-systemtap-sdt-devel.x86_64 : Static probe support tools
devtoolset-8-systemtap-server.x86_64 : Instrumentation System Server
devtoolset-8-systemtap-testsuite.x86_64 : Instrumentation System Testsuite
devtoolset-8-toolchain.x86_64 : Package shipping basic toolchain applications
devtoolset-8-valgrind.x86_64 : Tool for finding memory management bugs in programs
devtoolset-8-valgrind-devel.x86_64 : Development files for valgrind aware programs
devtoolset-9-annobin.x86_64 : Binary annotation plugin for GCC
devtoolset-9-annobin-annocheck.x86_64 : A tool for checking the security hardening status of binaries
devtoolset-9-binutils.x86_64 : A GNU collection of binary utilities
devtoolset-9-binutils-devel.x86_64 : BFD and opcodes static and dynamic libraries and header files
devtoolset-9-build.x86_64 : Package shipping basic build configuration
devtoolset-9-dwz.x86_64 : DWARF optimization and duplicate removal tool
devtoolset-9-dyninst.x86_64 : An API for Run-time Code Generation
devtoolset-9-dyninst-devel.x86_64 : Header files for compiling programs with Dyninst
devtoolset-9-dyninst-doc.x86_64 : Documentation for using the Dyninst API
devtoolset-9-dyninst-static.x86_64 : Static libraries for the compiling programs with Dyninst
devtoolset-9-dyninst-testsuite.x86_64 : Programs for testing Dyninst
devtoolset-9-elfutils.x86_64 : A collection of utilities and DSOs to handle ELF files and DWARF data
devtoolset-9-elfutils-devel.x86_64 : Development libraries to handle compiled objects
devtoolset-9-elfutils-libelf.x86_64 : Library to read and write ELF files
devtoolset-9-elfutils-libelf-devel.x86_64 : Development support for libelf
devtoolset-9-elfutils-libs.x86_64 : Libraries to handle compiled objects
devtoolset-9-gcc.x86_64 : GCC version 9
devtoolset-9-gcc-c++.x86_64 : C++ support for GCC  version 9
devtoolset-9-gcc-gdb-plugin.x86_64 : GCC 9 plugin for GDB
devtoolset-9-gcc-gfortran.x86_64 : Fortran support for GCC 9
devtoolset-9-gcc-plugin-devel.x86_64 : Support for compiling GCC plugins
devtoolset-9-gdb.x86_64 : A GNU source-level debugger for C, C++, Fortran, Go and other languages
devtoolset-9-gdb-doc.noarch : Documentation for GDB (the GNU source-level debugger)
devtoolset-9-gdb-gdbserver.x86_64 : A standalone server for GDB (the GNU source-level debugger)
devtoolset-9-libasan-devel.x86_64 : The Address Sanitizer static library
devtoolset-9-libatomic-devel.x86_64 : The GNU Atomic static library
devtoolset-9-libgccjit.x86_64 : Library for embedding GCC inside programs and libraries
devtoolset-9-libgccjit-devel.x86_64 : Support for embedding GCC inside programs and libraries
devtoolset-9-libgccjit-docs.x86_64 : Documentation for embedding GCC inside programs and libraries
devtoolset-9-libitm-devel.x86_64 : The GNU Transactional Memory support
devtoolset-9-liblsan-devel.x86_64 : The Leak Sanitizer static library
devtoolset-9-libquadmath-devel.x86_64 : GCC 9 __float128 support
devtoolset-9-libstdc++-devel.x86_64 : Header files and libraries for C++ development
devtoolset-9-libstdc++-docs.x86_64 : Documentation for the GNU standard C++ library
devtoolset-9-libtsan-devel.x86_64 : The Thread Sanitizer static library
devtoolset-9-libubsan-devel.x86_64 : The Undefined Behavior Sanitizer static library
devtoolset-9-ltrace.x86_64 : Tracks runtime library calls from dynamically linked executables
devtoolset-9-make.x86_64 : A GNU tool which simplifies the build process for users
devtoolset-9-memstomp.x86_64 : Warns of memory argument overlaps to various functions
devtoolset-9-oprofile.x86_64 : System wide profiler
devtoolset-9-oprofile-devel.x86_64 : Header files and libraries for developing apps which will use oprofile
devtoolset-9-oprofile-jit.x86_64 : Libraries required for profiling Java and other JITed code
devtoolset-9-perftools.x86_64 : Package shipping performance tools
devtoolset-9-strace.x86_64 : Tracks and displays system calls associated with a running process
devtoolset-9-systemtap.x86_64 : Programmable system-wide instrumentation system
devtoolset-9-systemtap-client.x86_64 : Programmable system-wide instrumentation system - client
devtoolset-9-systemtap-devel.x86_64 : Programmable system-wide instrumentation system - development headers, tools
devtoolset-9-systemtap-initscript.x86_64 : Systemtap Initscripts
devtoolset-9-systemtap-runtime.x86_64 : Programmable system-wide instrumentation system - runtime
devtoolset-9-systemtap-sdt-devel.x86_64 : Static probe support tools
devtoolset-9-systemtap-server.x86_64 : Instrumentation System Server
devtoolset-9-systemtap-testsuite.x86_64 : Instrumentation System Testsuite
devtoolset-9-toolchain.x86_64 : Package shipping basic toolchain applications
devtoolset-9-valgrind.x86_64 : Tool for finding memory management bugs in programs
devtoolset-9-valgrind-devel.x86_64 : Development files for valgrind aware programs


5.下载安装对应版本的gcc,比如我需要安装的是gcc9:

[root@VM_32_16_centos yum.repos.d]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.aliyun.com
 * centos-sclo-sclo: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package devtoolset-9-binutils.x86_64 0:2.32-16.el7 will be installed
--> Processing Dependency: devtoolset-9-runtime for package: devtoolset-9-binutils-2.32-16.el7.x86_64
---> Package devtoolset-9-gcc.x86_64 0:9.3.1-2.2.el7 will be installed
---> Package devtoolset-9-gcc-c++.x86_64 0:9.3.1-2.2.el7 will be installed
--> Processing Dependency: devtoolset-9-libstdc++-devel = 9.3.1-2.2.el7 for package: devtoolset-9-gcc-c++-9.3.1-2.2.el7.x86_64
--> Running transaction check
---> Package devtoolset-9-libstdc++-devel.x86_64 0:9.3.1-2.2.el7 will be installed
---> Package devtoolset-9-runtime.x86_64 0:9.1-0.el7 will be installed
--> Processing Dependency: /usr/sbin/semanage for package: devtoolset-9-runtime-9.1-0.el7.x86_64
--> Processing Dependency: /usr/sbin/semanage for package: devtoolset-9-runtime-9.1-0.el7.x86_64
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================================================================================
 Package                                                             Arch                                          Version                                                 Repository                                             Size
=======================================================================================================================================================================================================================================
Installing:
 devtoolset-9-binutils                                               x86_64                                        2.32-16.el7                                             centos-sclo-rh                                        5.9 M
 devtoolset-9-gcc                                                    x86_64                                        9.3.1-2.2.el7                                           centos-sclo-rh                                         32 M
 devtoolset-9-gcc-c++                                                x86_64                                        9.3.1-2.2.el7                                           centos-sclo-rh                                         12 M
Installing for dependencies:
 audit-libs-python                                                   x86_64                                        2.8.5-4.el7                                             os                                                     76 k
 checkpolicy                                                         x86_64                                        2.5-8.el7                                               os                                                    295 k
 devtoolset-9-libstdc++-devel                                        x86_64                                        9.3.1-2.2.el7                                           centos-sclo-rh                                        3.1 M
 devtoolset-9-runtime                                                x86_64                                        9.1-0.el7                                               centos-sclo-rh                                         20 k
 libcgroup                                                           x86_64                                        0.41-21.el7                                             os                                                     66 k
 libsemanage-python                                                  x86_64                                        2.5-14.el7                                              os                                                    113 k
 policycoreutils-python                                              x86_64                                        2.5-34.el7                                              os                                                    457 k
 python-IPy                                                          noarch                                        0.75-6.el7                                              os                                                     32 k
 setools-libs                                                        x86_64                                        3.3.8-4.el7                                             os                                                    620 k

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

Total download size: 55 M
Installed size: 156 M
Downloading packages:
(1/12): audit-libs-python-2.8.5-4.el7.x86_64.rpm                                                                                                                                                                |  76 kB  00:00:00     
(2/12): checkpolicy-2.5-8.el7.x86_64.rpm                                                                                                                                                                        | 295 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/centos-sclo-rh/packages/devtoolset-9-runtime-9.1-0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f2ee9d55: NOKEY
Public key for devtoolset-9-runtime-9.1-0.el7.x86_64.rpm is not installed
(3/12): devtoolset-9-runtime-9.1-0.el7.x86_64.rpm                                                                                                                                                               |  20 kB  00:00:00     
(4/12): libcgroup-0.41-21.el7.x86_64.rpm                                                                                                                                                                        |  66 kB  00:00:00     
(5/12): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                                                                                                | 113 kB  00:00:00     
(6/12): policycoreutils-python-2.5-34.el7.x86_64.rpm                                                                                                                                                            | 457 kB  00:00:00     
(7/12): python-IPy-0.75-6.el7.noarch.rpm                                                                                                                                                                        |  32 kB  00:00:00     
(8/12): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                                                                                                     | 620 kB  00:00:00     
(9/12): devtoolset-9-libstdc++-devel-9.3.1-2.2.el7.x86_64.rpm                                                                                                                                                   | 3.1 MB  00:00:00     
(10/12): devtoolset-9-gcc-9.3.1-2.2.el7.x86_64.rpm                                                                                                                                                              |  32 MB  00:00:02     
(11/12): devtoolset-9-gcc-c++-9.3.1-2.2.el7.x86_64.rpm                                                                                                                                                          |  12 MB  00:00:08     
devtoolset-9-binutils-2.32-16. FAILED                                                                91% [===================================================================================        ]  3.4 B/s |  50 MB 392:32:45 ETA 
http://mirrors.njupt.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-9-binutils-2.32-16.el7.x86_64.rpm: [Errno 12] Timeout on http://mirrors.njupt.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-9-binutils-2.32-16.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(12/12): devtoolset-9-binutils-2.32-16.el7.x86_64.rpm                                                                                                                                                           | 5.9 MB  00:00:00     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                  459 kB/s |  55 MB  00:02:02     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
Importing GPG key 0xF2EE9D55:
 Userid     : "CentOS SoftwareCollections SIG (https://wiki.centos.org/SpecialInterestGroup/SCLo) <[email protected]>"
 Fingerprint: c4db d535 b1fb ba14 f8ba 64a8 4eb8 4e71 f2ee 9d55
 Package    : centos-release-scl-rh-2-3.el7.centos.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                                                    1/12 
/sbin/ldconfig: /lib64/libevent_pthreads-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libevent-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_minimal.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_core-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_openssl-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libevent-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_extra-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_pthreads-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_debug.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libprotobuf-lite.so.20 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_minimal_debug.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libprotobuf.so.20 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_core-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_and_profiler.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_extra-2.0.so.5 is not a symbolic link

  Installing : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                                                                                               2/12 
  Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                                               3/12 
  Installing : python-IPy-0.75-6.el7.noarch                                                                                                                                                                                       4/12 
  Installing : checkpolicy-2.5-8.el7.x86_64                                                                                                                                                                                       5/12 
  Installing : libcgroup-0.41-21.el7.x86_64                                                                                                                                                                                       6/12 
/sbin/ldconfig: /lib64/libevent_pthreads-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libevent-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_minimal.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_core-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_openssl-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libevent-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_extra-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_pthreads-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_debug.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libprotobuf-lite.so.20 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_minimal_debug.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libprotobuf.so.20 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_core-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_and_profiler.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_extra-2.0.so.5 is not a symbolic link

  Installing : policycoreutils-python-2.5-34.el7.x86_64                                                                                                                                                                           7/12 
  Installing : devtoolset-9-runtime-9.1-0.el7.x86_64                                                                                                                                                                              8/12 
  Installing : devtoolset-9-binutils-2.32-16.el7.x86_64                                                                                                                                                                           9/12 
/sbin/ldconfig: /lib64/libevent_pthreads-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libevent-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_minimal.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_core-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_openssl-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libevent-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_extra-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_pthreads-2.1.so.6 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_debug.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libprotobuf-lite.so.20 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_minimal_debug.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libprotobuf.so.20 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_core-2.0.so.5 is not a symbolic link

/sbin/ldconfig: /lib64/libtcmalloc_and_profiler.so.4 is not a symbolic link

/sbin/ldconfig: /lib64/libevent_extra-2.0.so.5 is not a symbolic link

  Installing : devtoolset-9-libstdc++-devel-9.3.1-2.2.el7.x86_64                                                                                                                                                                 10/12 
  Installing : devtoolset-9-gcc-9.3.1-2.2.el7.x86_64                                                                                                                                                                             11/12 
  Installing : devtoolset-9-gcc-c++-9.3.1-2.2.el7.x86_64                                                                                                                                                                         12/12 
  Verifying  : libcgroup-0.41-21.el7.x86_64                                                                                                                                                                                       1/12 
  Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                                                                                                                       2/12 
  Verifying  : devtoolset-9-runtime-9.1-0.el7.x86_64                                                                                                                                                                              3/12 
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                                                                                                       4/12 
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                                               5/12 
  Verifying  : devtoolset-9-gcc-c++-9.3.1-2.2.el7.x86_64                                                                                                                                                                          6/12 
  Verifying  : devtoolset-9-binutils-2.32-16.el7.x86_64                                                                                                                                                                           7/12 
  Verifying  : policycoreutils-python-2.5-34.el7.x86_64                                                                                                                                                                           8/12 
  Verifying  : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                                                                                               9/12 
  Verifying  : devtoolset-9-gcc-9.3.1-2.2.el7.x86_64                                                                                                                                                                             10/12 
  Verifying  : devtoolset-9-libstdc++-devel-9.3.1-2.2.el7.x86_64                                                                                                                                                                 11/12 
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                                                   12/12 

Installed:
  devtoolset-9-binutils.x86_64 0:2.32-16.el7                                   devtoolset-9-gcc.x86_64 0:9.3.1-2.2.el7                                   devtoolset-9-gcc-c++.x86_64 0:9.3.1-2.2.el7                                  

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.5-4.el7      checkpolicy.x86_64 0:2.5-8.el7                  devtoolset-9-libstdc++-devel.x86_64 0:9.3.1-2.2.el7      devtoolset-9-runtime.x86_64 0:9.1-0.el7      libcgroup.x86_64 0:0.41-21.el7     
  libsemanage-python.x86_64 0:2.5-14.el7      policycoreutils-python.x86_64 0:2.5-34.el7      python-IPy.noarch 0:0.75-6.el7                           setools-libs.x86_64 0:3.3.8-4.el7           

Complete!

6.这个时候gcc还是临时的,退出shell之后就会被重置,执行一下:

scl enable devtoolset-9 bash

7.查看gcc版本:

[root@VM_32_16_centos yum.repos.d]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)

猜你喜欢

转载自blog.csdn.net/sirria1/article/details/127907260