Executive Summary / TL;DR
make uninstall (or
sudo make uninstall, if you had to run
sudo make install) from the build directory where you ran
make install. In builds configured with CMake, the build directory is usually not the top-level source directory. But besides that, uninstalling a program or library whose build was configured with CMake is no different from uninstalling other programs or libraries you have built from source code.
Some software supports
make install but not
make uninstall, in which case you may have to investigate what steps are taken when
make install is run, or consult the software's documentation to see if it specifies what files it puts where. However, PCL does appear to support uninstallation via
Installation and Uninstallation with
CMake is a system for configuring a build. Once configured, the build must usually be carried out using some build system. On Unix-like operating systems such as Ubuntu, builds configured with CMake almost always use the Make build system.
Most software that uses CMake requires that you create a separate build directory, usually called
build, and run the
cmake command from that directory. The build directory is populated with files necessary to perform the build. Then you run
make in that directory. You should create the
build directory wherever the instructions for the software you're building advise to put it. Usually it will be a subdirectory of the source tree's top-level directory (the highest level directory created when you unpacked the source tarball or invoked a version control system like
bzr to download the code).
When you run
make, it finds and reads a makefile -- usually called
Makefile -- that contains a list of targets, instructions for building the targets, and how the targets depend on one another. Usually the default target, which you do not have to specify, builds the software, and the
install target, which you do have to specify, installs it.
Many makefiles contain additional targets. The most common are:
test target that tests the software that has been built.
make check or
make test may be run before
make install, and it is usually advisable to do so.
uninstall target that uninstalls the software by removing the files created by running
make install. (Occasionally
make uninstall has other behavior as well, to undo actions of
make install other than copying files, but usually it's just a matter of deleting files.) Not all software has an
uninstall target, but these days most does.
clean target to delete files from the source or build directory that were created during the build. Nearly all makefiles have this.
There are a few other relatively common targets like
realclean that are less relevant to CMake. However, it's useful to know that if you're configured a build by running a configure script (
./configure) rather than CMake, then the configuration can usually be erased by running
A developer using CMake must write code to generate an
uninstall target -- CMake does not do this automatically. However, like many developers, the developers of PCL have done this and
make uninstall should work. See the next section ("A Step-By-Step Example") for details.
To uninstall software whose makefile supports an
- The directory from which you ran
make install (or
sudo make install) is the directory you must return to, to run
make uninstall (or
sudo make uninstall). For software that does not use CMake, this is usually the top-level directory of the source tree. But for software that does use CMake, it usually is not -- instead, it is usually a separate build directory.
- When installing software manually from source, it is best to keep the source code and all files created during the build, so you can uninstall the software easily. Therefore, once you have run
make install, it's best not to run
make clean (nor to manually delete any files).
- However, if you did run
make clean or delete the software's source code or build directory, it is still usually possible to uninstall successfully. Simply follow the same build steps, with the exact same version of the software, configured and built with the same options (or none if you didn't customize it), to get to the point where you can run
make uninstall (or
sudo make uninstall). For some software you may actually even have to run
make install again first, which will usually overwrite the files from the previous build. Then run
make uninstall (or
sudo make uninstall) as usual.
When there is no
uninstall target and you need to uninstall the software, you'll have to examine what files it creates. You can run
make -n install to show you what actions are taken by
make install. You do not need to run
make -n install with
sudo (assuming the initial
make didn't require
make is passed the
-n flag, it performs a dry run, which typically should not change anything, and therefore shouldn't need to do anything requiring elevated privileges.
A Step-By-Step Example: PCL 1.7.2
It's useful to give an example, and I might as well use the software you're actually trying to uninstall as that example. PCL 1.7.2 does appear to use
cmake to generate an
uninstall target in its makefile, and therefore should support
In addition to examining
uninstall_target.cmake.in, I have verified that the generated
Makefile contains an
uninstall target on a 64-bit Ubuntu 16.04 test system. However, I haven't finished building PCL so I can install it and then test
sudo make uninstall. (My test machine is very slow, and PCL is big.) I plan to update this with additional information when I get the chance to do so, sometime after the build has finished.
When you installed PCL 1.7.2, you probably did something like this:
tar xf pcl-1.7.2.tar.gz
sudo make -j2 install
That is based (loosely) on the official instructions, but of course may not be exactly what you did. In particular, I downloaded and unpacked
/usr/local/src. If you put it somewhere else then you'll have to replace
/usr/local/src with wherever you did put it.
/usr/local/src if necessary, you should be able to uninstall the software by running:
sudo make uninstall
Even if you ran
make -j2 install to allow multiple operations to take place simultaneously, there should be no need for you to pass the
-j2 flag when you run