OpenCV 2.4.9 QT issue with imread

asked 2014-05-14 08:54:11 -0500

I get an error when compiling with the cv::imread function (very basic one) included the right files and the .pro is good:

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets


INCLUDEPATH += /home/carlos/OpenCV/opencv-2.4.9

LIBS += -L /home/carlos/OpenCV/opencv-2.4.9/build/lib/

SOURCES += main.cpp\ mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

My main file is this:

include "mainwindow.h"

include "QApplication"

include "include/opencv/highgui.h"

include "modules/core/include/opencv2/core/core.hpp"

include "modules/highgui/include/opencv2/highgui/highgui.hpp"

using namespace std;

using namespace cv;

int main(int argc, char *argv[]){

QApplication a(argc, argv);
MainWindow w;;

Mat image = cv::imread("descarga.jpg",0);
namedWindow("My Image");
imshow("My Image", image);

return a.exec();


The error is:

/home/carlos/Programing/OpenCVTest/main.cpp:16: error: undefined reference to `cv::imread(std::string const&, int)'

I think is well implemented, is something wrong with code or it's just that it has changed for OpenCV 2.4.9?

edit retag flag offensive close merge delete


wait, shouldn't you link -lopencv_.a instead of ?

berak gravatar imageberak ( 2014-05-14 09:00:33 -0500 )edit