【问题标题】:Including OpenCV with CMake Linux包括 OpenCV 和 CMake Linux
【发布时间】:2013-04-08 19:54:54
【问题描述】:

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

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

它工作得很好,我没有改变任何东西....(真的!!!!)

今天我想在我的代码中添加一些额外的功能,我在我的 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&)'

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

【问题讨论】:

  • 如果您能提供导致这些错误的链接器命令会有所帮助——使用类似make VERBOSE=1

标签: linux opencv makefile cmake


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2012-02-21
    • 1970-01-01
    • 2013-11-04
    • 2020-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-15
    • 1970-01-01
    相关资源
    最近更新 更多