[英]Cmake can not find local version of opencv on ubuntu 18.04
I have a version of OpenCV ((3.4.1) compiled and installed in /home/m/locals/opencv我有一个版本的 OpenCV ((3.4.1) 编译并安装在 /home/m/locals/opencv
the content of /home/m/locals/opencv is: /home/m/locals/opencv 的内容是:
bin
include
lib
share
I have an eniroment pointing to this directory:我有一个指向这个目录的环境:
echo $OPENCV_ROOT
/home/m/locals/opencv
I have a cmake that tries to add opencv to project:我有一个尝试将 opencv 添加到项目的 cmake:
file(TO_CMAKE_PATH $ENV{OPENCV_ROOT} OpenCV_DIR)
set(BUILD_SHARED_LIBS OFF)
find_package(OpenCV COMPONENTS core highgui imgproc imgcodecs videoio photo stitching flann ml features2d calib3d objdetect REQUIRED)
when I run cmake, I am getting this error:当我运行 cmake 时,我收到此错误:
CMake Error at /usr/local/share/OpenCV/OpenCVModules.cmake:399 (message):
The imported target "opencv_core" references the file
"/usr/local/lib/libopencv_core.so.3.4.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.
My questions:我的问题:
You can do export OpenCV_DIR=...
as commented by @Tsyvarev. 您可以按照
export OpenCV_DIR=...
However, it may affect other builds that requires exactly 3.4.0
. 但是,它可能会影响其他需要
3.4.0
。 Rather, set the variable in your project's CMakeLists.txt
而是在项目的
CMakeLists.txt
设置变量
set(OpenCV_DIR /home/m/locals/opencv/share/OpenCV)
or, you can set the variable manually when running cmake: 或者,您可以在运行cmake时手动设置变量:
cmake -D OpenCV_DIR=/home/m/locals/opencv/share/OpenCV ..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.