I want to use OpenCV in a QT qmake project. The vrsions are opencv 4.9.0 and QT 5.15.2(MSV 2019,64bit).
.pro file
INCLUDEPATH += C:/opencv/build/include
LIBS += -LC:/opencv/build/x64/vc16/lib \
-lopencv_world490
mainwindow.cpp
#include <opencv2/opencv.hpp>
using namespace cv;
...
cv::Mat mat;
...
After build, I get the error: undefined reference to cv::Mat::Mat()
Hint: my project is a widget program with qmake (not cmake).
My problem finally resolved with the following actions:
I used 'OpenCV 4.5.2' (downloded from https://github.com/huihut/OpenCV-MinGW-Build) .
In the .cpp file replaced #include <opencv2/highgui.hpp> By '''#include <opencv2/highgui/highgui.hpp>'''
Copy .dll files (in the bin folder of opencv) to my project debug/release folder.
Hope this helps others too.