Last active
November 16, 2018 23:13
-
-
Save aakbar5/b25f3e80f7a4912cd618c84ecd284729 to your computer and use it in GitHub Desktop.
Manage multiple GCC installations on Ubuntu machine
This file contains 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
# | |
# Commands are tested on Ubuntu 14.04 | |
# | |
# Issue following command to verify which GCC version is installed | |
gcc --version | |
--- OR --- | |
g++ --version | |
gcc (Ubuntu 4.8.5-4ubuntu8~14.04.2) 4.8.5 | |
Copyright (C) 2015 Free Software Foundation, Inc. | |
This is free software; see the source for copying conditions. There is NO | |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
# Install the GCC-7 | |
sudo apt-get update -y && \ | |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && \ | |
sudo apt-get update -y && \ | |
sudo apt-get install gcc-7 g++-7 -y | |
# Let's manage two versions | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 20 --slave /usr/bin/g++ g++ /usr/bin/g++-7 | |
# Machine is configured for GCC-7 at this point, let's see | |
gcc --version | |
--- OR --- | |
g++ --version | |
gcc (Ubuntu 7.3.0-21ubuntu1~14.04) 7.3.0 | |
Copyright (C) 2017 Free Software Foundation, Inc. | |
This is free software; see the source for copying conditions. There is NO | |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
# To switch b/w different versions | |
sudo update-alternatives --config gcc | |
# To see available versions | |
sudo update-alternatives --list gcc | |
# To remove link | |
sudo update-alternatives --remove gcc /usr/bin/gcc-7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment