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