Indeed, there is no "uninstall" command when installing from source, unless the developer has decided to put one in. (i.e., it's not impossible for a developer to create a script that undoes everything)
Your only option is to go into /usr/local/bin/
and remove each file yourself. But which ones to remove?
One solution is to reinstall 5.4, but specify a new directory that isn't /usr/local/bin/
. This will give you a list of files that 5.4 installed. Then, using the list of files, go into /usr/local/bin/
and remove them manually. Note that it probably installed libraries and documentation into other directories, so to remove it completely, you will have to do more than just /usr/local/bin/
.
An alternative is to not do an uninstallation and just install gcc 4-8 on top of 5.4. It's the same program, but just a different version. So gcc
version 4.8 will overwrite 5.4. The "downside" is that you might have 5.4 files lying around, but they will just occupy (relatively little) space. It'll solve your problem and you can move ahead with what you want to do.
Of the two options, I'd pick the second one. The 5.4 files that remain won't affect your system. Relative to images, video, or almost any type of data, the space they occupy is fairly little (i.e., compiler, libraries, documentation is probably small). In the future, you should install it in another directory and add symbolic links manually. update-alternatives
would do that for you if it's a package installed compiler; but for a compiler installed from source, that isn't an option.
(Aside: Ubuntu 14.04 has reached end of life, I think. You might consider upgrading some day... If so, then what /usr/local/bin/
looks like won't matter anymore!)
update-alternatives
gives you the convenience of switching between different installed gcc versions. Downgrading the system gcc is almost never needed, and is generally harmful.
The error /usr/bin/gcc-6 doesn't exist
from update-alternatives
suggests that gcc-6
is not installed, so all you need is to install the following packages (which are found in the default 18.04 repository, bionic/universe
):
sudo apt-get install gcc-6 g++-6 g++-6-multilib gfortran-6
Then, repeat the sudo update-alternatives --install
step for each gcc version you wish to use.
Whenever you want to change back gcc
to point to the default version shipped with Bionic, 7.3, simply run sudo update-alternatives --config gcc
, which will let you pick between the available gcc versions with installed alternatives.
Also, you can always run a specific gcc version directly, by specifying the version suffix (gcc-6
, gcc-7
, etc).
Best Answer
Do
sudo update-alternatives --remove-all gccc
.