How to update default GCC on a CentOS 7.9?

mickael

Well-Known Member
Aug 3, 2014
57
9
58
cPanel Access Level
Root Administrator
Hi,

I updated GCC on my CentOS 7.9 from 4.8.5 to 9 by doing this:

yum install centos-release-scl -y
yum clean all
yum install devtoolset-9-* -y




And then I typed this:

scl enable devtoolset-9 bash

and the "gcc -v" command does return version 9, but every time I restart the dedicated server it reverts to version 4.8.5

How to enable gcc by default?

Cordially
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,306
2,439
363
cPanel Access Level
Root Administrator
Hey there! I'm not completely sure on this since this package is controlled by the operating system directly and isn't related to cPanel. On a CentOS 7 test machine, I also see version 4.8.5. It seems that this is a common question as I see a similar question posted here:


I'm also not seeing a consensus here either, as different answers all received many positive votes:

 

mickael

Well-Known Member
Aug 3, 2014
57
9
58
cPanel Access Level
Root Administrator
Hi @cPRex

Since this morning I haven't been idle, I tried to update and it seems to be a success

To start, I remove what I installed by mistake:
yum remove devtoolset-9-*

Then I :
949 2022-03-14 12:17:50 wget https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz
950 2022-03-14 12:20:03 tar -xvf gcc-9.2.0.tar.gz
951 2022-03-14 12:20:20 cd gcc-9.2.0
952 2022-03-14 12:20:27 ./configure
953 2022-03-14 12:21:51 sudo yum install glibc-devel.i686
954 2022-03-14 12:21:59 sudo yum install libgcc.i686
955 2022-03-14 12:22:15 ./configure
956 2022-03-14 12:22:39 gcc -v
957 2022-03-14 12:22:46 make

the make is very slow, you have to wait about 1h30
958 2022-03-14 14:33:50 history
959 2022-03-14 14:33:55 gcc --version

The version was still the same, I rebooted the server and then it's ok

[16:20:57] [email protected] [~]# gcc --version
gcc (GCC) 9.2.0
Copyright © 2019 Free Software Foundation, Inc.
Ce logiciel est un logiciel libre; voir les sources pour les conditions de copie. Il n'y a
AUCUNE GARANTIE, pas même pour la COMMERCIALISATION ni L'ADÉQUATION À UNE TÂCHE PARTICULIÈRE.
[16:23:52] [email protected] [~]#

[16:23:52] [email protected] [~]# gcc -v
Utilisation des specs internes.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Cible : x86_64-pc-linux-gnu
Configuré avec: ./configure
Modèle de thread: posix
gcc version 9.2.0 (GCC)
[16:25:22] [email protected] [~]#


That's how it is for those who don't know, or for me who needs to read the tutorial again, I'll come back here and read if I need to.

I hope it will go well for the future and that it will work.

[Edit]
I replaced the ./configure and make with:
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-plugin --enable-initfini-array --disable-libgcj --with-system-zlib
make -j 8


Greetings
 
Last edited:
  • Like
Reactions: cPRex

mickael

Well-Known Member
Aug 3, 2014
57
9
58
cPanel Access Level
Root Administrator
gcc --version
gcc -v

returned the new version
but not him:
/usr/bin/gcc -v

I replaced the ./configure and make with:
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-plugin --enable-initfini-array --disable-libgcj --with-system-zlib
make -j 8
faster, in 30 minutes it's good, instead of 1h30
now is ok :
[21:43:33] [email protected]# /usr/bin/gcc -v
Utilisation des specs internes.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Cible : x86_64-pc-linux-gnu
Configuré avec: ./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-plugin --enable-initfini-array --disable-libgcj --with-system-zlib
Modèle de thread: posix
gcc version 9.2.0 (GCC)
[21:45:39] [email protected] #


I hope that for the future there will be no problem

Before the changes, it displayed this config:

[19:53:24] [email protected] # /usr/bin/gcc -v
Utilisation des specs internes.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configuré avec: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Modèle de thread: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)