CMake OpenCV不能指定链接库 [英] CMake OpenCV Cannot Specify Link Libraries
问题描述
我想在Ubuntu上运行用C ++编写的OpenCV程序。我按照此教程安装OpenCV on
然后我按照 this 教程使用教程中指定的以下Cmake命令运行我的代码:
cmake_minimum_required (VERSION 2.8)
project(PedestrianDetection)
find_package(OpenCV REQUIRED)
add_executable(PedestrianDetection PedestrianDetection.cpp)
target_link_libraries($ {OpenCV_LIBS})
$然而,Cmake给了我以下输出: code> CMake错误:CMakeLists.txt:5(target_link_libraries):
无法为目标opencv_videostab指定链接库,该目录不是由此项目构建的
。
有人可能指向正确的方向链接图书馆吗?
顺便说一句,我使用OpenCV2.4.8
从文档
target_link_libraries:将目标链接到给定的库。
target_link_libraries(
target>
[item1 [item2 [...]]]
[[debug | optimized | general]< item>
] ...)
指定链接给定目标时要使用的库或标志。命名的
必须已通过
命令(如add_executable或add_library)在当前目录中创建。其余参数
指定库名称或标志。
请尝试
target_link_libraries(PedestrianDetection $ {OpenCV_LIBS})
I am trying to run an OpenCV program written in C++ on Ubuntu. I followed this tutorial to install OpenCV on my system.
I then followed this tutorial to run my code with the following Cmake commands as specified in the tutorial:
cmake_minimum_required(VERSION 2.8)
project( PedestrianDetection )
find_package( OpenCV REQUIRED )
add_executable( PedestrianDetection PedestrianDetection.cpp )
target_link_libraries( ${OpenCV_LIBS} )
However, Cmake gives me the following output:
CMake Error at CMakeLists.txt:5 (target_link_libraries):
Cannot specify link libraries for target "opencv_videostab" which is not
built by this project.
Can someone point me in the right direction to link the libraries?
By the way, I am using OpenCV2.4.8
from the documentation
target_link_libraries: Link a target to given libraries.
target_link_libraries(
<target>
[item1 [item2 [...]]] [[debug|optimized|general]<item>
] ...)Specify libraries or flags to use when linking a given target. The named must have been created in the current directory by a command such as add_executable or add_library. The remaining arguments specify library names or flags.
try instead
target_link_libraries(PedestrianDetection ${OpenCV_LIBS})
这篇关于CMake OpenCV不能指定链接库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!