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

How to prevent users from copying web page content using pure CSS

Preface When I was typing my own personal blog, I...

Ubuntu16.04 installation mysql5.7.22 graphic tutorial

VMware12.0+Ubuntu16.04+MySQL5.7.22 installation t...

How to deploy nextcloud network disk using docker

NextCloud You can share any files or folders on y...

React new version life cycle hook function and usage detailed explanation

Compared with the old life cycle Three hooks are ...

The practical process of login status management in the vuex project

Table of contents tool: Login scenario: practice:...

How to use cutecom for serial communication in Ubuntu virtual machine

Using cutecom for serial communication in Ubuntu ...

JavaScript implements div mouse drag effect

This article shares the specific code for JavaScr...

How to install grafana and add influxdb monitoring under Linux

Install grafana. The official website provides an...

JS implements circular progress bar drag and slide

This article example shares the specific code of ...

Summarize the common application problems of XHTML code

<br />For some time, I found that many peopl...

Vue implementation counter case

This article example shares the specific code of ...

How to write HTML head in mobile device web development

Copy code The code is as follows: <head> &l...