1
votes

I have a configuration problem while compiling and building a program with Qt Creator and the imageprocessing library openCV on my Windows machine. OpenCV worked some time ago with Visual Studio, but now I want to build programs with Qt Creator. I am working with opencv-2.4.11 and Qt Creator 3.3.2 I started a new program and tried to compile the following code:

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv/cv.h>

using namespace std;
using namespace cv;

int main()
{
    cout << "Hello World!" << endl;
    Mat Bild;
    return 0;
}

This building process ends with the errors:
C:...\build-Test01-Desktop_Qt_5_4_1_MinGW_32bit-Debug\debug\main.o:-1: In function ZN2cv3MatD1Ev': C:\opencv\build\include\opencv2\core\mat.hpp:278: Fehler: undefined reference tocv::fastFree(void*)' C:...\build-Test01-Desktop_Qt_5_4_1_MinGW_32bit-Debug\debug\main.o:-1: In function ZN2cv3Mat7releaseEv': C:\opencv\build\include\opencv2\core\mat.hpp:367: Fehler: undefined reference tocv::Mat::deallocate()' collect2.exe:-1: Fehler: error: ld returned 1 exit status

My .pro file includes the “INCLUDEPATH” and the “LIBS”:

INCLUDEPATH +=  C:\opencv\build\include\ \
                C:\opencv\sources\include\

LIBS += -L C:\opencv\build\x86\vc12\lib\
-lopencv_core2411\
-lopencv_calib3d2411\
-lopencv_highgui2411\
-lopencv_imgproc2411\

SOURCES += main.cpp

What am I doing wrong – why do I always get an error :( ?
I tried also different other ways to define the include folders and libs, but I was not able to compile the testcode.

Regards
matl

1

1 Answers

0
votes

You are using MinGW compiler and OpenCV extraction doesn't contain libraries built by it. So, you'll have to manually build them using MinGW provided by Qt. Use the following post for help:

How to link opencv in QtCreator and use Qt library

Make sure you have all the environment variables for Qt, MinGW and OpenCV libraries set properly. With all these done you should be all set.

Hope this helps.