gpt4 book ai didi

c++ - 使用 CMake 和 Make : cannot find -lopencv_bgsegm 编译时出现 OpenCV 库错误

转载 作者:太空宇宙 更新时间:2023-11-03 22:36:36 24 4
gpt4 key购买 nike

我试图建立一个位于 HERE 的仓库.按照说明,我创建了一个 CMakeLists,并更新了里面的目录地址。我不确定 OpenCV 路径,但找到了两个候选路径并将它们都插入了。

Cmake 很好,但是在执行 make 时,出现此错误,我猜这可能是由于 openCV 路径不正确。

这是详细的输出:

[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

问题是什么?如何解决?

这是 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
)

最佳答案

虽然您使用的 Github 存储库没有在文档中明确说明,但看​​来您不仅需要 OpenCV,还需要构建 extra OpenCV modules (由 this 回答提示)。缺少的 opencv_bgsegm 库由这些“额外”的 OpenCV 模块提供。

遵循 this 等教程,您应该包括 CMake 定义标志:

-DOPENCV_EXTRA_MODULES_PATH=/path/to/opencv_contrib/modules/

运行 cmake 时。这将确保构建额外的模块,并且 opencv_bgsegm 库将在您的系统上可用。

关于c++ - 使用 CMake 和 Make : cannot find -lopencv_bgsegm 编译时出现 OpenCV 库错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57776568/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com