Ask Your Question
0

VS 2015 C++ imwrite exception 0xC0000005

asked 2016-02-29 07:59:47 -0600

Yoga gravatar image

updated 2016-02-29 08:08:06 -0600

Dear all,

I am new to OpenCV and tried to create a simple opencv application using OpenCV31 under Visual Studio Community 2015. I created a C++ Win32 console application, here is my code:

int main(int argc, char* argv[])
{
Mat testImg(50, 50, CV_8U);
imwrite("C:\Users\Me\TestOut.jpg", testImg);
return 0;
}

But if I run this I get an access violation:

Exception at 0x00007FFAC9994D61 (opencv_world310.dll) 0xC0000005: Access violation on reading on position 0x00000201A183B000.

This happens if I use Visual Studio 2015 with Debug settings. If I switch to Release settings then the code works!?!

What goes wrong here?

Thanks for any help!

edit retag flag offensive close merge delete

Comments

2

In Debug, the dll should be: opencv_world310d.dll

Eduardo gravatar imageEduardo ( 2016-02-29 08:28:56 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-02-29 08:37:50 -0600

Yoga gravatar image

Hi Eduardo,

thanks that helped, by mistake I set the same lib under the Linker settings for Debug and Release settings. After I changed opencv_world310.lib into opencv_world310d.lib (Linker-->Input-->Additional dependencies)

it worked, thanks a lot!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-02-29 07:59:47 -0600

Seen: 3,761 times

Last updated: Feb 29 '16