Detailed process of upgrading gcc (version 10.2.0) under CentOS7 environment

Detailed process of upgrading gcc (version 10.2.0) under CentOS7 environment

Short Introduction

Hello everyone, today I will share with you how to upgrade the gcc compiler. The Linux system actually comes with a built-in gcc compiler, but the version is relatively low. Currently, some open source tools such as Apache Doris require a higher version of the gcc 5.3.1+ compiler to compile C++ code during installation. Then let's understand how to upgrade gcc (from 4.8.5 to 10.2.0).

1. Check the current gcc version

## Check the current system gcc version. Default is 4.8.5g++ -v or gcc --version 

439cdc8c22d5ec175b4675ff77c22220.png

2. Download the gcc installation package (version 10.2.0)

## Download address: http://ftp.gnu.org/gnu/gcc## Download via wget command under linux wget http://ftp.gnu.org/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.gz 

84f1e78dc6db592c9d826d540647ba87.png

0d411b8aa689ceeeae30834be4dd3369.png

3. Unzip the installation package

tar -xvf gcc-10.2.0.tar.gz## Unzip directory gcc-10.2.0 

70e965438fb0a3364c50d6b0be1b134d.png

4. Download dependent libraries

## Enter the unzipped directory and download the dependency library cd gcc-10.2.0./contrib/download_prerequisites 

b76aa7f533f1d7d363588a794ad27690.png

5. The installation system must include modules

yum install -y gcc-c++ libstdc++-static ant cmake byacc flex automake libtool binutils-devel bison ncurses-devel gcc kernel-devel libtool libatomic 

eed9c007d1b5936fcb471fbea3781e4f.png

6. Create a compilation directory

## Create a compilation directory in the same directory as gcc-10.2.0. The name is: gcc-build-10.2.0mkdir ../gcc-build-10.2.0 

87263594af49e29e6dc7a5375af12d2a.png

7. Generate Makefile

## Enter the compilation directory, execute the command, and generate the Makefile file cd gcc-build-10.2.0../gcc-10.2.0/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib 

1feac34f1c1384220825d48e54d96e99.png

illustrate:

If an error message is displayed, configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.

You need to delete the dependency package downloaded in step 4 and then execute it again. The correct packet sizes are as follows:

cc8083ef2c4de66a1ef170e09db8d611.png

d0870d82ec6645dc1a98fac4e9ae69ac.png

8. Compile

#Execute the command to compile. Here, 4 jobs are used. The compilation time is about 40 minutes. This value should not be set too high. make -j4 ## It is recommended to use nohup & execution, which is really slow. 

86cb7849f2ed32a29ab6e727ee523e7f.png

9. Installation

make install ## It is recommended to use nohup & to execute. It takes about 2 minutes to complete

10. Configure libstdc++.so

## Verify whether libstdc++.so exists in the compilation directory (gcc-build-10.2.0) find . -name "libstdc++.so*" 

7a5f2e50b517766be90a51b89b4631f9.png

## Enter the libstdc++.so configuration directory cd /usr/lib64 ## Copy the new libstdc++.so to the directory cp /root/gcc-build-10.2.0/stage1-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.28 . ## Backup mv libstdc++.so.6 libstdc++.so.6.old ## Create a new soft link ln -sv libstdc++.so.6.0.28 libstdc++.so.6 

eefcf342325df7e753f1d7c70afa518f.png

11. Configure environment variables

## Uninstall the old version 4.8.5yum remove gcc gcc-c++## Enter the root directorycd ~## Edit the current user environment variablevim .bash_profile## ContentPATH=$PATH:$HOME/bin:/usr/local/bin/export CC=/usr/local/bin/gccexport CXX=/usr/local/bin/g++## Take effect immediatelysource ~/.bash_profile## Verify gcc --version 

7f6f5c612556a7cdbeeb063e5bfa42ee.png

Summarize

During the gcc upgrade process, various module or package missing problems may occur. You need to install them one by one. In fact, this is also related to the Linux system environment itself. So don’t be afraid if you have problems, just solve them. I believe you can do it.

Finally, a small script for overall installation is attached

: : : : : : : : : : : : : : :

This is the end of this article about the detailed process of upgrading gcc (version 10.2.0) under CentOS7 environment. For more relevant CentOS upgrade gcc content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Manually upgrade gcc to gcc-6.1.0 in CentOS 6.5 in Linux
  • Linux super detailed gcc upgrade process

<<:  Implementing form submission without refreshing the page based on HTML

>>:  TypeScript Mapping Type Details

Recommend

JavaScript history object explained

Table of contents 1. Route navigation 2. History ...

Detailed explanation and extension of ref and reactive in Vue3

Table of contents 1. Ref and reactive 1. reactive...

jQuery implements the mouse drag image function

This example uses jQuery to implement a mouse dra...

Detailed explanation of Vue filter implementation and application scenarios

1. Brief Introduction Vue.js allows you to define...

GET POST Differences

1. Get is used to obtain data from the server, wh...

Detailed steps for building a React application with a Rails API

Table of contents Backend: Rails API part Front-e...

Nest.js hashing and encryption example detailed explanation

0x0 Introduction First of all, what is a hash alg...

Example code for configuring monitoring items and aggregated graphics in Zabbix

1. Install Zabbix Agent to monitor the local mach...

jQuery achieves full screen scrolling effect

This article example shares the specific code of ...

Detailed process of NTP server configuration under Linux

Table of contents 1. Environment Configuration 1....

Linux method example to view all information of the process

There is a task process on the server. When we us...

Design theory: Why are we looking in the wrong place?

I took the bus to work a few days ago. Based on m...