简体   繁体   English

无法使用 CMake 编译简单的 Opencv C++ 文件

[英]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.嗨,我正在尝试使用 Opencv 运行一个简单的 C++ 程序来显示图像文件,但出现以下错误。

The imported target "opencv_core" references the file导入的目标“opencv_core”引用文件

 "/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" “/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)调用堆栈(最近调用优先):/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其代码是 opencv 中给出的示例: 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*我之前尝试使用 opencv 3.2,但我卸载了 n 使用 sudo apt-get remove libopencv* 删除了所有 opencv 文件

I found similar question here: CMake does not find OpenCV but couldnt understand the answer.我在这里发现了类似的问题: CMake 没有找到 OpenCV但无法理解答案。 I have ROS Indigo installed on ubuntu 14.04.4.我在 ubuntu 14.04.4 上安装了 ROS Indigo。 Also, I tried to install Opencv 2.4.13 but when I am checking the version installed using following command另外,我尝试安装 Opencv 2.4.13,但是当我使用以下命令检查安装的版本时

pkg-config --modversion opencv pkg-config --modversion opencv

2.4.8 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 ?我得到 2.4.8 和主要问题为什么它引用文件 /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仅供参考,我按照此处给出的说明安装了 opencv: http : //docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation

Thank you谢谢

So I figured it out, apparently I had linking problem because of bad instalment.所以我想通了,显然由于分期付款错误,我遇到了链接问题。 I uninstalled opencv , deleted all the files and reinstalled it.我卸载了 opencv ,删除了所有文件并重新安装了它。 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.附加说明:根据我的观察,如果您安装了 ROS 并将 opt/ros/indigo/setup.bash 保存在 ~/.bashrc 中,它会出错,因此最好从 ~/.bashrc 中删除这些行,然后重试。

any other suggestion ??还有什么建议??

If you have more than one OpenCV installed in your computer, you could delete your OpenCV folder or you could move your folder to your temp folder:如果您的计算机中安装了多个 OpenCV,您可以删除您的 OpenCV 文件夹,或者您可以将您的文件夹移动到您的临时文件夹:

sudo mv /usr/local/share/OpenCV /temp/OpenCV

It worked for me!!它对我有用!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM