1

I did this to upgrade gcc from 4.8.5 to gcc 7:

sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
source /opt/rh/devtoolset-7/enable

This does give me the gcc 7 in the current bash terminal. However, if I start a python terminal, it displays that the gcc is still gcc 4.8.5, as below:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr --mandir=/opt/rh/devtoolset-7/root/usr/share/man --infodir=/opt/rh/devtoolset-7/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-7.3.1-20180303/obj-x86_64-redhat-linux/isl-install --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)

And in python terminal:

$ python
Python 3.7.4 (default, Feb 24 2020, 16:34:54) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.

Also, after I log off and log in back to the machine, the default gcc version is still 4.8.5 and I have to execute again:

source /opt/rh/devtoolset-7/enable

So I have two questions:

  1. after gcc 7 is enabled, how to make the python(3) version's gcc 4.8.5 become gcc 7 too?
  2. Is there a way to make the gcc 7 default in the whole centos system? And this might solve the problem of 1).
2

1 Answer 1

6

I've confirmed that you can upgrade gcc from the default version 4.8 on centOS 7.

First, we need to install "Software Collections" in order to access some of the community packages including gcc v7

  • sudo yum install -y centos-release-scl

Next, we want to install a developer toolset. Depending on your needs, you may want a different devtoolset. Here I'm targeting 7:

  • sudo yum install -y devtoolset-7

Finally, you'll want to change over to gcc 7 as your default, launch a new shell session with the scl tool:

  • scl enable devtoolset-7 bash

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .