mixing Debug and Realese builds of a library not working?
Hello,
I have a library and a simple application that uses the library. It works with these combinations:
library (debug) - application (debug)
library (release) - application (release)
but it does not work if I mix release and debug versions like this:
library (debug) - application (release)
library (release) - application (debug)
It seems to crash in wierd places.. any idea why this might be happening? Am I required to use debug version of a library with a debug application utilizing that library and vice versa?
By the way, my libraries are all statics .lib files.
Regards,
E. Khule
Re: mixing Debug and Realese builds of a library not working?
This can happen when classes exported from a library have configuration-dependent members. For example:
#ifdef _DEBUG
int m_nData;
#endif
Re: mixing Debug and Realese builds of a library not working?
It really depends on the code generation options. I'm assuming you're using visual studio. If you set both debug and release to use the same code generation options and remove any ignore statements from the linker, then it should work.
The problem is that the debug version is linked against one C runtime library while the release version is linked against another. If they're both linked against the same runtime library, then things should work better.
Re: mixing Debug and Realese builds of a library not working?
Quote:
Originally Posted by
ekhule
Am I required to use debug version of a library with a debug application utilizing that library and vice versa?
By the way, my libraries are all statics .lib files.
I'm not sure if its a requirement, but I do it anyway. To make it easier I change the output file of the debug version of the static lib to mylibd (I add 'd' to the end of the .lib name). Then in the application that uses the static lib, I use mylibd.lib for the debug config & mylib.lib for the release config.