How to Upgrade GCC on CentOS 8

If gcc is not installed,install it

dnf install gcc -y

CentOS 8 come with GCC 8.3.1. Check it with DNF dnf info gcc

Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:05:07 ago on Tue Aug 18 02:10:41 2020.
Available Packages
Name         : gcc
Version      : 8.3.1
Release      : 5.el8.0.2
Architecture : x86_64
Size         : 23 M
Source       : gcc-8.3.1-5.el8.0.2.src.rpm
Repository   : AppStream
Summary      : Various compilers (C, C++, Objective-C, ...)
URL          : http://gcc.gnu.org
License      : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
Description  : The gcc package contains the GNU Compiler Collection version 8.
             : You'll need this package in order to compile C code.

or by using gcc –version command:

gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

To Upgrade GCC to GCC 9.X, you must install Development Tools firs.

sudo dnf group install "Development Tools"

and install libmpc-devel:

dnf --enablerepo=PowerTools install libmpc-devel

download and install the specific GCC you want:

wget http://gnu.mirror.constant.com/gcc/gcc-$GCC_VERSION/gcc-9.2.0.tar.gz
tar zxf gcc-9.2.0.tar.gz
rm -rf gcc-build
mkdir gcc-build
cd gcc-build
../gcc-9.2.0/configure --enable-languages=c,c++ --disable-multilib
make -j$(nproc)
make install

make sure your GCC is successfully compiled with this command:

gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Wagiman Wiryosukiro

Petani Sistem Informasi, tukang las plugin & themes Wordpress. Co-Founder SistemInformasi.biz. Saat ini aktif sebagai Developer & kontributor di OpenMandriva Linux.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: