Created
June 10, 2021 08:25
-
-
Save bepcyc/8f0d29accdf777770da044594b0d19da to your computer and use it in GitHub Desktop.
Change default gcc /g++/ cpp version used in ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for advanced users only | |
# sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
GCC_VERSION=11 # or whatever | |
sudo apt update | |
sudo apt install gcc-${GCC_VERSION} gcc-${GCC_VERSION}-locales gcc-${GCC_VERSION}-multilib g++-${GCC_VERSION} g++-${GCC_VERSION}-multilib cpp-${GCC_VERSION} | |
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} 10 | |
# test with | |
g++-${GCC_VERSION} --version | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 10 | |
# test with | |
gcc-${GCC_VERSION} --version | |
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-${GCC_VERSION} 10 | |
# test with | |
cpp-${GCC_VERSION} --version | |
# revert with | |
# sudo update-alternatives --config g++ | |
# sudo update-alternatives --config gcc | |
# sudo update-alternatives --config cpp | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment