Short IntroductionHello 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 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 3. Unzip the installation packagetar -xvf gcc-10.2.0.tar.gz## Unzip directory gcc-10.2.0 4. Download dependent libraries## Enter the unzipped directory and download the dependency library cd gcc-10.2.0./contrib/download_prerequisites 5. The installation system must include modulesyum install -y gcc-c++ libstdc++-static ant cmake byacc flex automake libtool binutils-devel bison ncurses-devel gcc kernel-devel libtool libatomic 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 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 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: 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. 9. Installationmake 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*" ## 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 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 SummarizeDuring 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:
|
<<: Implementing form submission without refreshing the page based on HTML
>>: TypeScript Mapping Type Details
1. Virtual Machine Preparation 1. Create a new vi...
Table of contents 1. Route navigation 2. History ...
Table of contents 1. Ref and reactive 1. reactive...
This example uses jQuery to implement a mouse dra...
Installation path: /application/mysql-5.7.18 1. P...
1. Brief Introduction Vue.js allows you to define...
Table of contents Add traffic function to github+...
1. Get is used to obtain data from the server, wh...
Table of contents Backend: Rails API part Front-e...
0x0 Introduction First of all, what is a hash alg...
1. Install Zabbix Agent to monitor the local mach...
This article example shares the specific code of ...
Table of contents 1. Environment Configuration 1....
There is a task process on the server. When we us...
I took the bus to work a few days ago. Based on m...