Ask Your Question
0

imwrite in different building mode(debug, release)

asked 2013-06-04 00:56:58 -0600

Trung gravatar image

updated 2013-06-04 08:37:16 -0600

I am using Visual studio 2012 and openCV 2.4.5.

I have a very simple code to write the image to a file:

imwrite("example.png", image);

I build the program in Win32 console debug mode.

When I link

#pragma comment(lib, "opencv_highgui245D.lib")

there is no problem and the program works well.

When I link

#pragma comment(lib, "opencv_highgui245.lib")

the program fails.

I guess the problem is because I use the different library "opencv_highgui245.lib" vs "opencv_highgui245D.lib". However, a large number of other functions (including cvSaveImage), I do not have such problem no matter debug or release-mode library is used.

Any one could you tell me the problem?

Thank you very much!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-06-04 08:40:35 -0600

Basically, there are debug libraries for the reason of debugging. They contain tons of lines of code as overhead, with the sole purpose to do different asserts, output more information and make it possible to actually go through the code while debugging.

However, when people release software, they do not want this overhead, which slows down the program drastically, to be included. For that release libraries are provided, which do not contain this extra information.

Never build in debug mode with release libraries or vice versa. Basically it will always get you into trouble. Not for these simple functions like saving an image, but with more complex functionality it will always fail on you.

Just keep being concise and stick to one selection.

edit flag offensive delete link more

Comments

Thank you so much Steven!!

Trung gravatar imageTrung ( 2013-06-04 20:08:12 -0600 )edit

You are welcome, feel free to accept my answer as solution if it fulfilled your needs :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-06-05 01:54:03 -0600 )edit

Question Tools

Stats

Asked: 2013-06-04 00:56:58 -0600

Seen: 768 times

Last updated: Jun 04 '13