本文说的方法是通过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) <security@centos.org>"
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)
CentOS 离线安装gcc
折腾了一天,功夫不负有心人,终于整出来了,还是很激动的呵呵。废话就不多说了,直接进入正题。
首先,在CentOS下安装gcc4.8.2需要先安装GMP,MPFR 和 MPC 三个包。
安装包下载地址
从http://gcc.gnu.org/下载gcc安装包 gcc-4.8.2.tar.gz
从ftp://ftp.gnu.org/gnu/gmp/ 下载GMP安装包 gmp-5.1.3 .tar.bz2
从http://ftp.gnu.org/gnu/mpfr/ 下载MPFR安装包 mpfr-3.1.2.tar.gz
从http://www.cise.ufl.ed
正文开始@Assassin
目录:CentOS 7升级GCC基本执行步骤:1. 切换用户:2. 安装centos-release-scl:3. 安装devtoolset:4. 激活对应的devtoolset:5. 查看gcc版本号:6. 一些issue:
我们在centos下默认的gcc版本是gcc4.8.5,版本比较低,默认是支持编译c++98的,若在C++程序中直接使用到c++11的特性,则会报错。
解决方案: 在编译时加上-std=c++11即可,如g++ test.cp
GCC介绍
GCC是GNU编译器套件,是由GNU开发的编程语言的编译器。GNU编译器套件包括C、C++、Objective-C、Fortran、Java、Ada和Go语言及这些语言的库,使用gcc编译程序时,编译过程可以为4个阶段:预处理(Pre-Processing)、编译(Compiling)、汇编(Assembling)、链接(Linking)
由于 Linux 操作系统的自由开源,在其基础上衍生出了很多不同的 Linux 操作系统,如 CentOS、Ubuntu、Debian 等,这些Linux发行
mpfr-2.4.2.tar.bz2
注意:若linux主机可以联网,则可以使用gcc-4.8.2目录下的contrib/download_prerequisites脚本自动下载
编译安装gcc
我们在RPM 仓库中,提供 CentOS 7.9 的二进制 RPM 安装包最高只到 4.8.5 了,这个和 yum intall gcc 能安装的最高版本一致,没有再高的了。gcc 在 github 上没有,它放在 gnu 自己的仓库中了,https://gcc.gng.org 可以下载,或者使用 git 直接 clone。下载这三个组件依次安装,如果没有 bzip2 的用 yum install bzip2 安装上,然后。如果我们想安装更高的GCC 版本,怎么办,只能手工编译源码来做了。
然后就可以安装Developer Toolset 7、8、9、10、11等了。首先安装centos-release-scl。当然,也可以通过加入环境变量的方式使用。要使用新版本gcc,只需要执行以下命令。
su root //进入管理员命令
yum -y install gcc gcc-c++ kernel-devel //安装gcc、c++编译器以及内核文件
2.验证安装是否成功
gcc -v
二.gcc编译器的使用
1.在终端创建c++文件
touch project1.c
2.打开c文件
vim project1.c
3.c语言代码编辑并保存
当输入c语言程序的时候,可能会发现在打开的.c文件中无法进行插入编辑...
本文介绍在CentOS7.8系统下使用YUM升级GCC版本的相关操作步骤。
CentOS7默认安装的gcc版本是4.8版本,gcc 4.8最主要的一个特性就是全面支持C++11,如果不清楚什么用的也没关系,简单说一些C++11标准的程序都需要gcc 4.8以上版本的gcc编译器编译。很多工具依赖的是更高版本的gcc,比如编译MySQL 8.0(8.0.16以上版本是C++14标准,需gcc 5.3以上版本)、Redis 6.
由于我们安装的CenOS是最小安装版,所以需要自己动手,才能丰衣足食。除了基本的命令和编辑工具,现在什么都没有(包括网络)。CentOS可以用yum来安装和升级软件(熟悉使用yum来维护软件之后,会发现很便捷),所以当务之急是需要让虚拟机联网。1、登陆root后,在命令端(扔掉鼠标)输入:vi /etc/sysconfig/network-scripts/ifcfg-eth02、编辑网络配置文件:...
首先确认自己未安装gcc。我先是用源码包的方式安装,遇见各种坑。通过查阅发现出现这个“Linux系统安装gcc报错noacceptableCcompilerfoundin$PATH”这个问题的原因是用源码的方式去安装gcc,但是犯了一个错,凡是源码安装库都需要gcc去编译的。一般情况是不用源码去安装gcc了,除非系统上已经有了一定版本的gcc,才用源码去安装其他版本的gcc。...