Removing all installed OpenCV libs

175,780

Solution 1

By default, when building OpenCV from source, it will place it's output in /usr/local/lib and /usr/local/bin. Although, judging from your error messages, it looks like it placed the libraries in /usr/lib and the binaries in /usr/bin, so you might also check in there.

You can also use the Linux find command. So, to find all OpenCV libraries you can do the following (this might take a while):

$> sudo find / -name "*opencv*" -exec rm -i {} \;

The above command will find any file containing opencv in the name, and will prompt you to remove it. As always, be careful when deleting things manually!

Another option might be to manually compile OpenCV again (exactly as you did before), make install to create the install manifest, and then try make uninstall to see if it will clean up itself.

Hope that helps! :)

Solution 2

If you have the build directory then it is recommended to execute:

 $ sudo make uninstall

from the build directory as per @Navid 's answer

But this will leave few .so* files somewhere

To completely remove all such files, do:

$ sudo rm /usr/local/{bin,lib}/*opencv* 

/usr/local is what we normally set CMAKE_INSTALL_PREFIX to while running cmake. Replace it according to how you executed cmake

Solution 3

You can do a sudo make uninstall for a clean uninstall

Solution 4

I couldn't find the build directory so did:

sudo apt-get purge '*opencv*'

And:

sudo find / -name "*opencv*" -exec rm -rf {} \;

Which seems to have worked fine.

You can double check with:

sudo find / -name "*opencv*";

Solution 5

In order to remove all the files and folders without "interaction", use the below command :

sudo find / -name "*opencv*" -exec rm -rf {} \;

CAUTION: It's not advisable to run "recursive" and "force" deletion.

Share:
175,780
flak37
Author by

flak37

Updated on August 07, 2022

Comments

  • flak37
    flak37 almost 2 years

    I'm running Kubuntu 11.10 (w/ KDE 4.8)

    Before you read all this :

    I just want to remove all traces of OpenCV from my system, so I can start afresh..

    The whole story

    I first installed python-opencv and libopencv (2.1 I think) from https://launchpad.net/~gijzelaar/+archive/opencv2 a long time ago. I only tried python-opencv at that time, which worked perfectly (I didn't attempt using C++ code using OpenCV)

    Then I recently tried to install OpenCV 2.3.1 from source, which got installed but while compiling my own C++ code (using OpenCV), it gave me errors about libgtk not installed and also broke my python opencv code which was running fine earlier

    So I installed the libgtk2-dev libraries and compiled and installed OpenCV 2.3.1 again..

    The error still occured, so I deleted the untarred OpenCV directory from which I was running cmake, make ,etc. I did NOT make uninstall (which I now realize was my mistake)

    and instead installed the ubuntu opencv 2.3 package (with all dependencies) from here : https://launchpad.net/~gijzelaar/+archive/opencv2.3

    Now the problem is I still get the same error when I compile my C++ code which includes OpenCV , and the error still points to my (deleted) OpenCV source folder :

    OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/anant/opencv/OpenCV-2.3.1/modules/highgui/src/window.cpp, line 275
    terminate called after throwing an instance of 'cv::Exception'
      what():  /home/anant/opencv/OpenCV-2.3.1/modules/highgui/src/window.cpp:275: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow
    

    As you can see the error still points to the directory from where I had compiled and installed OpenCV

    Is there a way to completely remove all traces of my compiled version of OpenCV and just keep the files from the ubuntu package? As I mentioned earlier I did not 'make uninstall' and have also (foolishly) deleted the install-manifest

    EDIT: I ran the package manager again,and found that not all opencv packages from the ppa had gotten installed properly. So I did a sudo apt-get install opencv again, and now I get this error:

    Unpacking libopencv2.3 (from .../libopencv2.3_2.3.1-3_amd64.deb) ...
    dpkg: error processing /var/cache/apt/archives/libopencv2.3_2.3.1-3_amd64.deb (--unpack):
     trying to overwrite '/usr/lib/libopencv_video.so.2.3.1', which is also in package libopencv-video2.3 2.3.1-4ppa1
    dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
    Unpacking opencv (from .../opencv_2.3.1-3_amd64.deb) ...
    dpkg: error processing /var/cache/apt/archives/opencv_2.3.1-3_amd64.deb (--unpack):
     trying to overwrite '/usr/bin/opencv_haartraining', which is also in package libopencv-core-dev 2.3.1-4ppa1
    dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
    Errors were encountered while processing:
     /var/cache/apt/archives/libopencv2.3_2.3.1-3_amd64.deb
     /var/cache/apt/archives/opencv_2.3.1-3_amd64.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    I just want to remove all traces of OpenCV from my system, so I can start afresh