OpenCV:对imread()的未定义引用 [英] OpenCV : undefined reference to imread()

查看:1671
本文介绍了OpenCV:对imread()的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Eclipse Mars中配置了OpenCV 3.1.0.这些是我的配置,

I have configured OpenCV 3.1.0 in Eclipse Mars. These are my configuration,

G ++包含:D:/opencv/build/install/include; GCC包含:D:/opencv/build/install/include

G++ includes: D:/opencv/build/install/include; GCC includes: D:/opencv/build/install/include

链接器库:libopencv_core310,libopencv_highgui310

Linker libraries: libopencv_core310, libopencv_highgui310

链接器库路径:D:/opencv/build/lib(此目录中的文件类似于libopencv_core310.dll.a)

Linker libraries path: D:/opencv/build/lib (files in this directory are like libopencv_core310.dll.a)

我遇到这样的错误,

imageRead.cpp:15: undefined reference to `cv::imread(cv::String const&, int)'

这是我的imageRead.cpp文件,

This is my imageRead.cpp file,

#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"

using namespace std;
using namespace cv;

int main(int argc, const char** argv) {
    Mat img = imread("D:/sample.jpg", CV_LOAD_IMAGE_UNCHANGED);
    if (img.empty()) {
        cout << "Error: Image cannot be loaded." << endl;
        system("pause");
        return -1;
    }
    namedWindow("Image Window", CV_WINDOW_AUTOSIZE);
    imshow("Image Window", img);
    if (waitKey() == 27) {
        return -1;
    }
    destroyWindow("Image Window");
    return 0;
}

任何人都可以帮助解决此错误吗?

Can anyone help with this error ?

推荐答案

自OpenCV3起,imread函数驻留在imgcodecs模块中.将opencv_imgcodecs库添加到项目后,Imread应该会起作用(注意:imgcodecs,而不是imcodecs).

Since OpenCV3, the imread function resides in the imgcodecs module. Imread should work once you add the opencv_imgcodecs library to your project (note: imgcodecs, not imcodecs).

这篇关于OpenCV:对imread()的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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