OpenCV不能指定链接库

Cmake OpenCV Can not specify link libraries

本文关键字:链接 不能 OpenCV      更新时间:2023-10-16

我想运行这段我在网上找到的c++/OpenCV代码:

http://docs.opencv.org/doc/tutorials/features2d/feature_homography/feature_homography.html

我有一个问题与CMake,它返回这个错误:

CMake Error at CMakeLists.txt:5 (target_link_libraries)不能为目标"SURF_Homography"指定链接库

我在网上搜索了解决方案,我发现了这个

CMake OpenCV不能指定链接库

但我不能理解为什么我的不工作,因为它看起来一样,这是我的CMakeLists文件:

cmake_minimum_required(VERSION 2.8)
project( SURF_Homography )
find_package( OpenCV REQUIRED )
add_executable( SURF_Homography.cpp SURF_Homography.cpp )
target_link_libraries( SURF_Homography ${OpenCV_LIBS} )

希望你能帮助我谢谢卢卡

更改add_executable行:

add_executable( SURF_Homography SURF_Homography.cpp )

否则,您在target_link_libraries行中指定的目标将不存在:)