Search code examples
c++opencvcmakeros

fail to compile simple Opencv C++ file with CMake


Hi I am trying to run a simple C++ program with Opencv to display Image file but I am getting following error.

The imported target "opencv_core" references the file

 "/usr/local/lib/libopencv_core.so.3.2.0"

but this file does not exist. Possible reasons include:

  • The file was deleted, renamed, or moved to another location.

  • An install or uninstall procedure did not complete successfully.

  • The installation package was faulty and contained

    "/usr/local/share/OpenCV/OpenCVModules.cmake"

    but not all the files it references.

Call Stack (most recent call first): /usr/local/share/OpenCV/OpenCVConfig.cmake:111 (include) CMakeLists.txt:3 (find_package)

-- Configuring incomplete, errors occurred!

The code for which is an example given in opencv here: http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html#linux-gcc-usage

I tried to use opencv 3.2 before but I uninstalled n deleted all the opencv files using sudo apt-get remove libopencv*

I found similar question here: CMake does not find OpenCV but couldnt understand the answer. I have ROS Indigo installed on ubuntu 14.04.4. Also, I tried to install Opencv 2.4.13 but when I am checking the version installed using following command

pkg-config --modversion opencv

2.4.8

I am getting 2.4.8 and the main question why its referencing the file /usr/local/lib/libopencv_core.so.3.2.0 ?

FYI I installed opencv as per the instructions given here: http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation

Thank you


Solution

  • So I figured it out, apparently I had linking problem because of bad instalment. I uninstalled opencv , deleted all the files and reinstalled it. I could have solved it using symlink as well but figured its best to clear everything and reinstall it. worked perfectly.

    Additional note : Its my observation that if you have ROS installed and saved the opt/ros/indigo/setup.bash in ~/.bashrc , it will give errors so better remove those lines from ~/.bashrc and then try again.

    any other suggestion ??