You will need to use the devtoolset builds to do this:
There is a gcc 8 .. but not gcc 9
https://www.softwarecollections.org/en/scls/rhscl/devtoolset-8/
I did install gcc 8 from devtoolset-8 (SCL repo). However I am unable to
compile 32-bit programs because devtoolset-8-libstdc++-devel.i686 package is missing from CentOS SCL repository. This is mentioned here https://bugzilla.redhat.com/show_bug.cgi?id=1642077 as well.
g++ -m32 helloworld.cpp /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: skipping incompatible /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++_nonshared.a when searching for -lstdc++_nonshared /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: cannot find -lstdc++_nonshared collect2: error: ld returned 1 exit status
Are there any plans to add the missing i686 package? Otherwise, what other options does one have to get to gcc 8/9?
Further, where can I find the srpm file for the devtoolset-8 packages. One way would be to use the srpm to rebuild.