Uninstall programs compiled from source code

Q I usually uninstall apps by using apt-get remove in Ubuntu. Recently, I have started compiling programs from source, but then have problems uninstalling them. I tried to use make uninstall, but to do this you always need the Makefile present. So do I always have to save my Makefiles to uninstall apps that I've installed by compiling them? That isn't really practical.

A You can recreate the Makefile by unpacking the source tarball again and running ./configure in its directory. Note that if you passed any options to ./configure the first time you unpacked the tarball, you must give the same options again. Then you can run make uninstall from inside the source directory. However, there is a better solution; one that integrates self-compiled programs with your package manager, so everything can be uninstalled (or updated) in the same way. Install CheckInstall, and use this instead of make install. The installation process then becomes

sudo checkinstall --type=debian --install=yes

As you can see, the call to CheckInstall replace make install. This runs make install, then builds a Debian package and installs it with dpkg. The result is that the software you've just compiled is not only installed but visible in Synaptic, from where you can uninstall it. There are many more options for CheckInstall it's not limited to packages that use make install (all of which are described in the documentation), but this is enough to get you going.

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar