This is a follow up question to How to install gcc-7 or clang 4.0?.
Following the answers therein, I was able to install gcc-7.2 by:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y gcc-7
However, after the install, the gcc
/g++
command still defaults to 5.4.0
gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
Is it possible/safe to have gcc-7
as the default and remove the old gcc-5.x files entirely?
Note that, different from the said duplicate, I'm looking to remove/replace gcc-5.x instead of setting a symlink.
To answer my own question after much trial and error, it seems not safe to remove/replace the older gcc (gcc-5), because it will break a lot of dependencies to the extent of wiping out the entire tool chain.
For example, when trying to remove/replace gcc-5 as said in the comments with
This generates an error:
When adding these dependencies to the list of
sudo dpkg -r
items, an increasing number of packages need to be removed. e.g.I haven't tried to find the largest set of packages that will be removed as described in How to uninstall a .deb package? . But it's pretty clear that most of the useful packages in the Ubuntu will be gone by then.