Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall gcc installed from source?

How can I uninstall a gcc build which I installed from source.I am using gcc 4.9 and I'm on ubuntu 12.04.

Or is there a way to upgrade to latest gcc versions through the ubuntu repository?

like image 400
user1423561 Avatar asked Aug 14 '14 08:08

user1423561


People also ask

How to uninstall GCC from Ubuntu?

You can uninstall or removes an installed gcc package itself from Ubuntu 16.10 (Yakkety Yak) through the terminal, If you would like to remove gcc and it's dependent packages which are no longer needed from Ubuntu, If you use with purge options to gcc package all the configuration and dependent packages will be removed.

Do I need GCC to install programs?

Note that, you might need GCC for some programs. If you face any driver issues while installing programs / drivers you can install the latest GCC by using: Thanks for contributing an answer to Stack Overflow!

How do I uninstall a source package in Ubuntu?

Also if you have installed a source with traditional method, you can reinstall the package placing yourself in the same directory from where you have runned sudo make install, running sudo checkinstall . You will can then uninstall it by simply typing sudo apt-get purge $program_name

What is the highest version of GCC I can install?

The highest available version of GCC in the 12.04 repositories is 4.6. You can use the package manager to install a newer version, but you will have to add a PPA. This link should help, although it is for a slightly older version of GCC (but can be used for the newest version).


2 Answers

When you build a package from source there is unfortunately no magic uninstall usually, however you can approximate this, credit to this mailing list thread.

Basically you should install again into a temporary directory and list all the files created in said directory, then you can delete all of them from the main system through a script.

Here is an example of a script to uninstall GCC in this way:

make install DESTDIR=/tmp/gccinst
find /tmp/gccinst | sed -e s,/tmp/gccinst,, | \
(while read F; do rm "$F"; done)

Run it from inside the gcc source directory as root.

To answer your second question you can install the latest gcc available in the ubuntu repo with:

apt-get install gcc

Overlay repos may have newer versions, I have seen a suggestion there is a newer version at ubuntu-toolchain-r/test (install via):

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

But I am not sure if they have added 4.9 there yet. If not you will indeed have to install from source.

EDIT:

It looks like @roelofs found a better guide to install the repo in his answer, so go look there too and remember to give him an upvote if it helps :)

like image 50
Vality Avatar answered Oct 22 '22 01:10

Vality


In GCC 5.1.0, although there is no top-level uninstall target, some directories do have it, in particular gcc, so you can do:

cd build/gcc
sudo make uninstall

This does not remove everything that was installed, but it removes major executables like gcc, g++, cpp... contained in that directory, so it might be enough.