[英]OpenCV library error when compiling with CMake and Make: cannot find -lopencv_bgsegm
I was trying to build a repo located HERE .我试图建立一个位于HERE 的仓库。 As per instructions, I created a
CMakeLists
, and updated the directory addresses inside.按照说明,我创建了一个
CMakeLists
,并更新了里面的目录地址。 I was not sure about the OpenCV path, but found two candidates and inserted both.我不确定 OpenCV 路径,但找到了两个候选并插入了两个。
Cmake
is good, but when doing make
, I get this error, which I guess is maybe due to the openCV path being incorrect. Cmake
很好,但是在执行make
,我收到此错误,我想这可能是由于 openCV 路径不正确。
Here is the VERBOSE output:这是 VERBOSE 输出:
[100%] Linking CXX executable SimpleVideoSummExample
/usr/bin/cmake -E cmake_link_script CMakeFiles/SimpleVideoSummExample.dir/link.txt --verbose=1
/usr/bin/c++ -O3 -std=c++0x -std=c++0x -fopenmp -s CMakeFiles/SimpleVideoSummExample.dir/src/utils/ShotDetector.cc.o CMakeFiles/SimpleVideoSummExample.dir/src/videoSummarization/SimpleVideoSummarizer.cc.o CMakeFiles/SimpleVideoSummExample.dir/src/utils/ColorUtils.cc.o CMakeFiles/SimpleVideoSummExample.dir/src/utils/ImageUtils.cc.o CMakeFiles/SimpleVideoSummExample.dir/examples/SimpleVideoSummExample.cc.o -o SimpleVideoSummExample -L/usr/local/Cellar/opencv/3.4.1_2/lib -rdynamic libsummengine.a -lopencv_imgproc -lopencv_core -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_bgsegm -lopencv_video -lopencv_objdetect -lopencv_dnn -Wl,-rpath,/usr/local/Cellar/opencv/3.4.1_2/lib
/usr/bin/ld: cannot find -lopencv_bgsegm
collect2: error: ld returned 1 exit status
CMakeFiles/SimpleVideoSummExample.dir/build.make:199: recipe for target 'SimpleVideoSummExample' failed
make[2]: *** [SimpleVideoSummExample] Error 1
What is the problem?问题是什么? How to fix it?
如何解决?
Here is the directory part of CMakeLists
(Cellar is the git repo's user):这是
CMakeLists
的目录部分(Cellar 是 git repo 的用户):
include_directories(/usr/local/Cellar/opencv/3.4.1_2/include/ /usr/local/Cellar/opencv/3.4.1_2/include/opencv/ /usr/include/opencv /usr/local/include/opencv$
link_directories(/usr/local/Cellar/opencv/3.4.1_2/lib/)
add_executable(SimpleVideoSummExample src/utils/ShotDetector.cc src/videoSummarization/SimpleVideoSummarizer.cc src/utils/ColorUtils.cc src/utils/ImageUtils$
target_link_libraries(SimpleVideoSummExample
summengine -lopencv_imgproc
-lopencv_core
-lopencv_highgui
-lopencv_videoio
-lopencv_imgcodecs
-lopencv_bgsegm
-lopencv_video
-lopencv_objdetect
-lopencv_dnn
)
Although the Github repository you are using doesn't explicitly state it in the documentation, it appears you not only need OpenCV, but also need to build the extra OpenCV modules (hinted by this answer).尽管您使用的 Github 存储库没有在文档中明确说明,但您似乎不仅需要 OpenCV,还需要构建额外的OpenCV 模块( this answer暗示)。 The missing
opencv_bgsegm
library is provided by these "extra" OpenCV modules.缺少的
opencv_bgsegm
库由这些“额外的”OpenCV 模块提供。
Following a tutorial such as this , you should include the CMake definition flag:继这样一个教程的这个,你应该包括CMake的定义标志:
-DOPENCV_EXTRA_MODULES_PATH=/path/to/opencv_contrib/modules/
when running cmake
.运行
cmake
。 This will ensure the extra modules are built, and the opencv_bgsegm
library will be available on your system.这将确保构建额外的模块,并且
opencv_bgsegm
库将在您的系统上可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.