Switching
8. Switching System GCC
Finally, to easy Managing GCC Versions use update-alternatives
So first install the New GCC 12.2.x with, for instance:sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/x86_64-pc-linux-gnu-gcc-12.1.0 10
In case, replace 12.2.0 with your current version in the above Command.
To check it run:ls /usr/local/bin | grep gcc-12
The grep Command refine the output List showing only the Entries matching the Keyword.
And then the to Setup also the System GCC use:sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/gcc 20
Next to Switch between GCC Versions play:
sudo update-alternatives --config gcc
Last, to test the GCC in use:
gcc -v
![Step-by-step GCC 12.2 Installation in Ubuntu 22.04 Guide - update-alternatives GCC](https://tutorialforlinux.com/wp-content/media/dg139/terminal/updateAlternatives-configGcc10.png)
Congratulations, your GCC 12.2 should be now nicely working on Ubuntu 22.04. Good Luck! :)