I am new in learning C++. I have used this code to show an image, but there is an error that I do not understand!

This is the simple code:

include iostream

include conio.h

include opencv2/core.hpp

include opencv2/highgui.hpp

include opencv2/opencv.hpp

include opencv2/imgproc.hpp

using namespace cv;

using namespace std;

int main()

{ std::cout << "Hello World!\n";

Mat img = imread("lena.jpg");

namedWindow("input image", WINDOW_NORMAL);

imshow("image", img);


return 0;


enter image description here

when I run, system.cpp will open and "Exception Unhandled" will be apear!!! here is a picture of that, may you help please!

  • 2
    $\begingroup$ I'm voting to close this question as off-topic because it belongs on a software or coding stack. $\endgroup$ – Solar Mike Jan 17 at 10:35
  • $\begingroup$ Welcome to Engineering! This question seems more relevant to Stack Overflow. $\endgroup$ – Wasabi Jan 18 at 0:50

I have found the solution! I did these three steps and everything is ok now!

1) I restored my system through: start/create a restore point/ system protection/ system restore/next/next...

2) I work with visual studio 2019 and I have two kind of libraries: v14 and v15, so I add both directories into the libraries direction

3) copy my code to new project!!

after these steps, the code works properly :D

| improve this answer | |
  • $\begingroup$ If you accept this answer to close out the question, that would be great! $\endgroup$ – J. Ari Jan 17 at 16:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.