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
.bashrcor.bash_profileor create a new file under/etc/profile.d/with the following:source scl_source enable gcc-toolset-12 - i thought
scl_sourcewould go away in el8, el9 but apparently not - for more info on
scl_sourcego to this link https://unix.stackexchange.com/a/195219/5510 or Permanently enable RHEL scl
- edit your user
p.s. what is the difference between alternatives and update-alternatives?
- the original tool is called
update-alternativesand is from Debian linux distro - in EnterpriseLinux, Redhat rewrote the tool and called it
alternativesand when you installalternativesthe package also installs a symlink with nameupdate-alternativeson your env varPATHto help you find the tool - the two are similar but not the same because their source code is different
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
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.