This issue in this case is RedHat subscription channels. Though the subscription and software are free (provided you have an active subscription already), for some reason you have to make a 'special request' to RedHat as per:
https://access.redhat.com/solutions/472793
You can automate this by visiting:
https://www.redhat.com/wapps/try/RHSCL
(when logged into the support portal). This should automatically be approved after which you can attach a new subscription. Identify the pool id using:
subscription-manager list --available --all
To find the pool id:
Subscription Name: Software Collections and Developer Toolset
Provides: Red Hat Developer Tools (for RHEL Server)
Red Hat Developer Tools Beta (for RHEL Workstation)
Red Hat Software Collections Beta (for RHEL Server)
Red Hat Software Collections Beta (for RHEL Workstation)
Red Hat Software Collections (for RHEL Server)
Red Hat Developer Tools Beta (for RHEL Server)
Red Hat Developer Toolset (for RHEL Workstation)
Red Hat Software Collections Beta (for RHEL Client)
Red Hat Software Collections (for RHEL Workstation)
Red Hat Developer Toolset (for RHEL Server)
Red Hat Developer Tools (for RHEL Workstation)
Red Hat Software Collections (for RHEL Client)
SKU: foobar
Contract: 1234 Pool ID: XXXXXXXXXX
Then attach this and enable the newly available repos:
>subscription-manager attach --pool=XXXXXXXXXXXXXXXXXXXX
Successfully attached a subscription for: Software Collections and Developer Toolset
>subscription-manager repos --enable rhel-workstation-rhscl-7-rpms
Repository 'rhel-workstation-rhscl-7-rpms' is enabled for this system.
>subscription-manager repos --enable rhel-7-workstation-devtools-rpms
Repository 'rhel-7-workstation-devtools-rpms' is enabled for this system.
You can now install freely:
>yum update -y
>yum install -y devtoolset-7-gcc-c++
Quite why they make you jump through so many hoops is explained by RedHat as follows:
Answer from Bruce Adams on Stack Overflow-If you have a 2013 RHEL SKU with Standard or Premium service level, there should be no action on your part, and your subscription should have full access to RHSCL.
-If you have a 2010 or older RHEL SKU with Standard or Premium service level, you should contact Red Hat Customer Service to request the RHSCL SKU (and all related content) added to your account.
NOTE: Developer Toolset is now included as part of Red Hat Software Collections. This change was made on May 29, 2014.
As you had Red Hat Enterprise Linux Workstation, Standard subscription which is older RHEL SKU with Standard service level, you had to initiate a special request for it
Announcing release of Developer Toolset 7 on CentOS Linux 7 x86_64 SCL - announce - lists.centos.org
Scl enable devtoolset-7 bash on Rocky 9
Can CMake automatically detect RH devtoolset-7?
Devtoolset is a game changer for C++ development on Linux
what is devtoolset ?
More on reddit.comI had this problem as well. I don't know why scl was failing to enable the environment, but I was able to get it to load with source /opt/rh/devtoolset-7/enable.
It is because of your settings in .bashrc and/or .bash_profile. scl appends its path to gcc7 before starting your new bash shell, but the path to gcc is default to the old gcc4 again because your .bashrc appends /usr/bin to the path when starting the new bash, and it supersedes the scl settings. The solution is to use the "enable" script directly. That way no further path settings annoy you.
On Linux the dependency on system compilers have always been frustrating since it means your stuck with ancient GCC versions. But I must say I'm very impressed with devtoolset for RHEL/CentOS, it means you can use gcc-7 on old crappy RHEL6 that so many large companies insist on using. And you can ship the resulting binaries and it will run on plain vanilla RHEL installations!
what is devtoolset ?
devtoolset-7 also provides newer versions of lots of supporting debug and performance tools like gdb.
They (RH or Centos) also provide containerised versions of the build tools and the performance tools.
There is also a tech preview of the llvm-toolset, admittedly at clang v4 but still able to build those compatible binaries.
Note that you want to build using a host that is lower or same version as your minimum target version.
e.g. toolset-7 on host centos v6.7 will create bins compatible with 6.7, 6.9 and 7.x If your host is say centos 7.2 toolset-7 builds are only guaranteed to be compatible with v7.2+ targets.
Redhat's documentation is really good (and you can even get a free developer login to access more resources).
Also note that Centos provides similar options to RHEL.
The only downside is I don't think you can use the new ABI variant of CXX LIB as the ABI isn't compatible with older compilers like the default Centos gcc 4
Not really a problem as you can still use the C++11/14/17 features, just a few items are incompatible (such as list::size() still being O(n) and not const time, or strings still being COW)
https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ (Lots of other tools/langs etc there too like Go,Rust,Python3 and lots of database updated versions etc.)
Not sure if you need to have a developer account, but an example of the documentation: https://access.redhat.com/documentation/en-us/red_hat_developer_toolset/7/html/7.0_release_notes/dts7.0_release