Switching
-
8. Switching System GCC
(Optional) Finally, to easy Managing GCC Versions use Alternatives
So now to Set System for to manage a Multi Compiler.
First, possibly disable the existing Target with:sudo mv /usr/local/bin/gcc /usr/local/bin/gcc.bak
Then to Add the New GCC with alternatives use:
sudo alternatives --install /usr/local/bin/gcc gcc /usr/bin/x86_64-redhat-linux-gcc 20
Again Add the System GCC:
sudo alternatives --install /usr/local/bin/gcc gcc /usr/bin/gcc 10
(The Setup is working if as of default /usr/local/bin is preceding /usr/bin on the $PATH Env Var)
Next to Switch between GCC Versions play:sudo alternatives --config gcc
Last, to test the GCC in use:
gcc -v
If not working then you may need to amend the User’s PATH with:
echo "export PATH=/etc/alternatives:$PATH" >> ~/.bashrc
And then to Reload it simply run:
bash
Congratulations, your GCC 11.2 should be now nicely working on CentOS 8. Good Luck! :)
Contents