Skip to content

Instantly share code, notes, and snippets.

@vvrs
Created April 28, 2020 15:36
Show Gist options
  • Save vvrs/9c3dc0abe7ba314f7183a0650ee9ffea to your computer and use it in GitHub Desktop.
Save vvrs/9c3dc0abe7ba314f7183a0650ee9ffea to your computer and use it in GitHub Desktop.
Install different versions of gcc and g++. Update alternatives.
#!/bin/sh
sudo apt install build-essential
sudo apt -y install gcc-6 g++-6 gcc-7 g++-7 gcc-8 g++-8 gcc-9 g++-9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9
# use sudo update-alternatives --config gcc/g++ to update the compiler version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment