I used `imwrite()` function in Qt Creator. I failed to run the code in Debug mode,while successfully in Release mode.
 I wrote a test program.The followings is what I have done:
 First to use `OpenCV`, I added the following code in .pro:

```
INCLUDEPATH+=D:\Work_Software\OpenCV3.1\opencv\build\include
LIBS+=D:\Work_Software\OpenCV3.1\opencv\build\x64\vc12\lib\*.lib

```

Then I added a Push Button. The slot function is:

```
 void MainWindow::on_pushButton_clicked()
{
    Mat img;
    img=imread("F:\\My_Desktop\\foot1.jpg",0);
    imwrite("F:\\My_Desktop\\result.jpg",img);
    namedWindow("test");
    imshow("test",img);
    waitKey(0);
}

```

Finally, in Release mode, I can successfully read and write the image. However, failed to write in Debug mode. The error information is:

![error information](https://i.stack.imgur.com/QpmcX.jpg)

**UPDATE**

`imread` works in debug mode, for example, I change the slot function into:

```
void MainWindow::on_pushButton_clicked()
{
    Mat img;
    img=imread("F:\\My_Desktop\\foot1.jpg",0);
    namedWindow("test");
    imshow("test",img);
    waitKey(0);
    imwrite("F:\\My_Desktop\\result.jpg",img);

}

```

I can successfully load and `imshow` the image in Debug mode, but when I closed the windows, the same error happened.

The content of lib folder：

[![my lib](https://i.stack.imgur.com/am1UD.jpg)](https://i.stack.imgur.com/am1UD.jpg)

I have just seen a problem like mine [similar problem](https://stackoverflow.com/q/24852639/6666850 "similar problem") , but it could not fix mine.