in a nutshell, here are some examples for how to install and configure

  • for python3 to get python3.9: dnf install -y python39 && alternatives --set python3 $(command -v python3.9)
  • for gcc to get gcc-12: dnf install gcc-toolset-12 && source scl_source enable gcc-toolset-12
  • for java to get java-17: dnf install java-17 && bin_java_filename=$(rpm -qa|grep java-17|xargs rpm -ql|grep "bin\/java$"|head -1) && alternatives --set java ${bin_java_filename}
  • tested on rocky8, rocky9

which repo has the newer software versions?

  • the old method using "SCL" was deprecated
  • the new method is to use a repo called "appstream"
  • here is a post written by the distro maintainers explaining the change https://developers.redhat.com/blog/2018/11/15/rhel8-introducing-appstreams
  • the repo is enabled by default

how to: install newer software versions?

  • for python3: dnf install python39
  • for gcc: dnf install gcc-toolset-12

how to: change the system default?

  • for python3: alternatives --set python3 $(command -v python3.9)
  • for gcc:
    • edit your user .bashrc or .bash_profile or create a new file under /etc/profile.d/ with the following: source scl_source enable gcc-toolset-12
    • i thought scl_source would go away in el8, el9 but apparently not
    • for more info on scl_source go to this link https://unix.stackexchange.com/a/195219/5510 or Permanently enable RHEL scl

p.s. what is the difference between alternatives and update-alternatives?

  • the original tool is called update-alternatives and is from Debian linux distro
  • in EnterpriseLinux, Redhat rewrote the tool and called it alternatives and when you install alternatives the package also installs a symlink with name update-alternatives on your env var PATH to help you find the tool
  • the two are similar but not the same because their source code is different
Answer from Trevor Boyd Smith on Stack Overflow
🌐
Red Hat
catalog.redhat.com › en › software › containers › rhel8 › gcc-toolset-12-toolchain › 62da36e05522f33d987d670b
GCC Toolset 12 Toolchain - Red Hat Ecosystem Catalog
November 5, 2024 - rhel8/gcc-toolset-12-toolchain ... will require authentication. View other options. Base image with essential libraries and tools used to build C and C++ applications....
🌐
Pkgs.org
pkgs.org › download › gcc-toolset-12-gcc
Gcc-toolset-12-gcc Download for Linux (rpm)
Search and download Linux packages for Adélie, AlmaLinux, Alpine, ALT Linux, Arch Linux, CentOS, Debian, Fedora, KaOS, Mageia, Mint, OpenMandriva, openSUSE, OpenWrt, RHEL, Rocky Linux, Slackware, Solus, Ubuntu and Void Linux distributions
🌐
Red Hat
developers.redhat.com › articles › 2025 › 04 › 16 › gcc-and-gcc-toolset-versions-rhel-explainer
GCC and gcc-toolset versions in RHEL: An explainer | Red Hat Developer
April 16, 2025 - For example, gcc-toolset-12 is available in RHEL 9, but its support ended in November 2024 (after two years) as part of the Application Streams life cycle.
🌐
RPMfind
rpmfind.net › linux › rpm2html › search.php
RPM resource gcc-toolset-12-gcc-c
The search service can find package by either name (apache), provides(webserver), absolute file names (/usr/bin/apache), binaries (gprof) or shared libraries (libXm.so.2) in standard path. It does not support multiple arguments yet · The System and Arch are optional added filters, for example ...
Top answer
1 of 1
1

in a nutshell, here are some examples for how to install and configure

  • for python3 to get python3.9: dnf install -y python39 && alternatives --set python3 $(command -v python3.9)
  • for gcc to get gcc-12: dnf install gcc-toolset-12 && source scl_source enable gcc-toolset-12
  • for java to get java-17: dnf install java-17 && bin_java_filename=$(rpm -qa|grep java-17|xargs rpm -ql|grep "bin\/java$"|head -1) && alternatives --set java ${bin_java_filename}
  • tested on rocky8, rocky9

which repo has the newer software versions?

  • the old method using "SCL" was deprecated
  • the new method is to use a repo called "appstream"
  • here is a post written by the distro maintainers explaining the change https://developers.redhat.com/blog/2018/11/15/rhel8-introducing-appstreams
  • the repo is enabled by default

how to: install newer software versions?

  • for python3: dnf install python39
  • for gcc: dnf install gcc-toolset-12

how to: change the system default?

  • for python3: alternatives --set python3 $(command -v python3.9)
  • for gcc:
    • edit your user .bashrc or .bash_profile or create a new file under /etc/profile.d/ with the following: source scl_source enable gcc-toolset-12
    • i thought scl_source would go away in el8, el9 but apparently not
    • for more info on scl_source go to this link https://unix.stackexchange.com/a/195219/5510 or Permanently enable RHEL scl

p.s. what is the difference between alternatives and update-alternatives?

  • the original tool is called update-alternatives and is from Debian linux distro
  • in EnterpriseLinux, Redhat rewrote the tool and called it alternatives and when you install alternatives the package also installs a symlink with name update-alternatives on your env var PATH to help you find the tool
  • the two are similar but not the same because their source code is different
Find elsewhere
🌐
RPMfind
rpmfind.net › linux › rpm2html › search.php
RPM resource gcc-toolset-12-gcc
The gcc-toolset-12-gcc package contains the GNU Compiler Collection version 10.
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_developer_toolset › 12 › html › user_guide › chap-gcc
Chapter 2. GNU Compiler Collection (GCC) | User Guide | Red Hat Developer Toolset | 12 | Red Hat Documentation
In Red Hat Developer Toolset, the GNU C++ compiler is provided by the devtoolset-12-gcc-c++ package and is automatically installed with the devtoolset-12-toolchain package as described in Section 1.5, “Installing Red Hat Developer Toolset”.
🌐
Centos
lists.centos.org › hyperkitty › list › discuss@lists.centos.org › thread › POTHJYRWJSSESJ3TWDHO76JIMAXZBYCS
Package of GCC 12 on CentOS 7 - Discuss - lists.centos.org
Is there an rpm of GCC 12 (or at least higher than 9) available to download and install, or is it a case of downloading and build from the source yourself?
🌐
AWS re:Post
repost.aws › questions › QUjmH7VQ6fToCjUZaEdYgR2Q › rhel-8-10-devtoolset-12
RHEL 8.10 devtoolset-12 | AWS re:Post
February 10, 2025 - To install gcc-toolset-12 on your RHEL 8.10 instance in AWS, you should be able to use the standard package manager (dnf or yum) to install it from the RHUI repositories.
Top answer
1 of 4
50

gcc-12 is not available in ubuntu 20.04, so we need to compile it from source code, here are the steps which I borrowed from this video:

  • Step 1: clone gcc source code and checkout gcc-12 branch
$ git clone https://gcc.gnu.org/git/gcc.git gcc-source
$ cd gcc-source/
$ git branch -a
$ git checkout remotes/origin/releases/gcc-12
  • Step 2: make another build dir

Note this is important as running ./configure from within the source directory is not supported as documented here.

$ mkdir ../gcc-12-build
$ cd ../gcc-12-build/
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
  • Step 3: installing GCC prequisites and run configure again

The missing libraries will be shown in above ./confgiure output, search and install them one by one.

$ apt-cache search MPFR
$ sudo apt-get install libmpfrc++-dev
$ apt-cache search MPC | grep dev
$ sudo apt-get install libmpc-dev
$ apt-cache search GMP | grep dev
$ sudo apt-get install libgmp-dev
$ sudo apt-get install gcc-multilib
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++

An alternative is to run the download_prerequisites script.

$ cd ../
$ cd gcc-source/
$ ./contrib/download_prerequisites
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
  • Step 4: compile gcc-12
$ make -j16

Still flex is missing:

$ sudo apt-get install flex
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
$ make -j16
$ make install

Another way is to use Ubuntu 22.04 where gcc-12 is available. In Ubuntu 22.04, gcc-12 can be installed with apt:

$ sudo apt install gcc-12
2 of 4
16

You can use Homebrew to install pre-built binaries. Follow instructions to install Homebrew at https://brew.sh/, then

brew install gcc for default GCC (currently 11) or brew install gcc@12 for gcc-12.

Note that it may compile missing dependencies.

🌐
LLVM
llvm.org
The LLVM Compiler Infrastructure Project
The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Despite its name, LLVM has little to do with traditional virtual machines. The name "LLVM" itself is not an acronym; it is the full name of the project · LLVM began as a research project at the University ...
🌐
RPMfind
rpmfind.net › linux › rpm2html › search.php
RPM resource gcc-toolset-12-libstdc -devel(x86-64)
The search service can find package by either name (apache), provides(webserver), absolute file names (/usr/bin/apache), binaries (gprof) or shared libraries (libXm.so.2) in standard path. It does not support multiple arguments yet · The System and Arch are optional added filters, for example ...
🌐
NVIDIA
docs.nvidia.com › cuda › cuda-installation-guide-linux
CUDA Installation Guide for Linux — Installation Guide for Linux 13.3 documentation
1 month ago - Each installation method includes detailed pre-installation requirements (CUDA-capable GPU, supported OS version, GCC compiler), step-by-step procedures, and post-installation configuration including environment setup, sample verification, and integration with development tools like Nsight and CUDA-GDB.
🌐
mingw-w64
mingw-w64.org
mingw-w64
Mingw-w64 is a collection of header files, import libraries, libraries and tools that, when combined with a compiler toolchain, such as GCC or LLVM, provides a complete development environment for building native Windows applications and libraries.