Install older gcc/g++ versions in CentOS 8

Viewed 3672

I've been struggling with this for the past 2h. In CentOS 8 I can't find the devtoolset packages to install older gcc/g++ versions. There is no longer a scl repo for CentOS 8. I need gcc/g++ 4.9x installed along the current gcc/g++ 8.x and I need to be able to switch between the two. This was extremely easy to set up in Ubuntu, not the case in CentOS and the documentation is non-existent or I had trouble finding it.

2 Answers

Found a solid path that has automated compiling and packaging gcc, as well as a guide:

I won't copy paste what's in this person's guide as they deserve the credit. However, here's a summary of the steps:

  1. Install your prereqs (rpm build tools, devtools for bootstrapping your environment).
  2. Clone the repo.
  3. Checkout a branch in the repo like the major version of GCC you want (e.g. gcc7).
  4. In the repo, edit gcc-build-vars.sh such that it points to a version of GCC you want from http://gnu.mirror.constant.com/gcc/.
  5. Perform the build with: ./build-gcc.sh -T | tee build.log.
  6. Stage it: ./stage-gcc.sh.
  7. Package it: (./pack-gcc.sh or ./make-gcc-rpm.sh -v).
Related