Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV 4.1.1 Imread() & Imwrite() Crashes Program Immediately [Qt] ?


I have built OPENCV v4.1.1 from source for Qt. I have linked the necessary libraries and added the include path in the .pro file as follows:

INCLUDEPATH += "C:\opencv4-build-x64\install\include"

LIBS += -L"C:\opencv4-build-x64\install\x64\mingw\bin" -lopencv_core411 \
-lopencv_highgui411 \
-lopencv_imgproc411 \

The libraries are .dll files. Now in my source code, I have something like this:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>

int main(){

Mat img = imread("SamplePath.tiff", IMREAD_GRAYSCALE);


The program builds fine but when I try to run it, it crashes immediately. If I comment out all the imread() and imwrite() functions, then it runs perfectly.

Any ideas ? Thanks.