Opencv Program Compile Error "Libopencv_Core.So.2.4: Cannot Open Shared Object File: No Such File or Directory" in Ubuntu 12.04

OpenCV : libopencv_core.so.2.4: cannot open shared object file: No such file or directory

just open file called /etc/ld.so.conf.d/opencv.conf, then insert

 /usr/local/opencv/

then type: sudo ldconfig

libopencv_gpu.so.2.4: cannot open shared object file: No such file or directory

I found the problem, it is what i have been expected:
I add in the source file:
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());

And it returned:

OpenCV Error: No GPU support (The library is compiled without CUDA support) in getDevice, file /build/buildd/opencv-2.4.2+dfsg/modules/core/src/gpumat.cpp, line 182
terminate called after throwing an instance of 'cv::Exception'
what(): /build/buildd/opencv-2.4.2+dfsg/modules/core/src/gpumat.cpp:182: error: (-216) The library is compiled without CUDA support in function getDevice

Now I have to compile opencv with cuda (CMAKE). But i have ever done this part...

Impossible to install OpenCV Ubuntu (libopencv_core error)

I finally managed to solve my problems. Since this may interested other people, here how I proceed.

  1. I removed entirely opencv from my computer:

    • sudo make unistall in the repository where I wrote sudo make install
    • sudo find / -name "*opencv*" -exec rm -i {} \; to remove all files containing "opencv"
    • sudo find / -name "*cv2.so*" -exec rm -i {} \; to remove all files containing "cv2.so"
    • conda uninstall opencv (if needed)
  2. I followed this link to install OpenCV2.4.10 for Python2.7: I did only the points 5,6,7 and 12 (the remaining ones are useless for what I wanted). I changed a bit the cmake command and I typed

    cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON  -D WITH_OPENGL=ON -D WITH_VTK=ON -D WITH_GTK=ON .. 
  3. Now if when typing import cv2 in Python you get an error like "No module named cv2", edit your .bashrc file with the following command

    export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

You will have to reload the .bashrc file (source .bahsrc) to apply the change.


  1. Finally I rebooted my computer. And it worked!

To conclude, I don't know why it did not work previously but it appears that with this version of OpenCV I did not encounter any problem!

Good luck!

Can't find libopecv_core.so.2.3, file actually not there

If you really can not find the shared library, it seems to me that you have not installed openCV properly. You might have downloaded openCV but not built the libraries, I assume?

Since you are using Ubuntu you can install openCV from the Ubuntu repository
sudo apt-get install libopencv-dev python-opencv



Related Topics



Leave a reply



Submit