在CMake Linux中包含OpenCV [英] Including OpenCV with CMake Linux

查看:175
本文介绍了在CMake Linux中包含OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天我制作了一个"CMakeLists.txt"文件,其中包含以下内容.

yesterday I made a "CMakeLists.txt" file, that contained the following.

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

工作正常,我还没有更改任何内容....(真的!!!)

It worked fine, I havent Changed anything.... (really!!!!)

今天,当我想向代码中添加一些额外的功能时,我在Linux Shell上获得了以下输出.

Today as I wanted to Add some Extra functions to my Code I got the following Output on my Linux Shell.

HMirror.cpp:(.text+0x56): undefined reference to `cv::imread(std::string const&, int)'
HMirror.cpp:(.text+0x191): undefined reference to `cv::namedWindow(std::string const&, int)'
HMirror.cpp:(.text+0x1f1): undefined reference to `cv::namedWindow(std::string const&, int)'
HMirror.cpp:(.text+0x268): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
HMirror.cpp:(.text+0x2df): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'

自昨天以来,我没有更改过图书馆的目的地,也没有更改过代码.所以我想知道为什么它似乎不再起作用了.

I haven't changed the librarys destination and havent changed the code since yesterday. So I wonder Why it doesn't seem to work anmore.

推荐答案

尝试明确编写要链接的库.在Linux上,这将是opencv_coreopencv_highguiopencv_imgproc等...

Try to write explicitly which libraries to link. On Linux, this would be opencv_core,opencv_highgui,opencv_imgproc, etc...

如果从源代码编译库,则从名称中减去lib前缀后,即可在/usr/local/lib中找到库名称.

If You compiled library from sources, the library names would be found in /usr/local/lib, after subtracting lib prefix from names.

这篇关于在CMake Linux中包含OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆