I’m building static libraries (right now libpng) in Microsoft Visual Studio 2008 SP1.
Do I have any possibility to build single library (one file) for both Debug and Release modes assuming that my library has only C code in it?
As far as I remember, gtkmm, for instance, has it’s pre-built package, where C++ based libraries are shipped in both Debug and Release versions, but other – as a single file only.
E.g. they have gtkmm-vc90-d-2_4.lib and gtkmm-vc90-2_4.lib files for C++ based libraries and they have single libraries such as gtk-win32-2.0.lib for both Debug and Release configurations.
How can I achieve the same effect? What should I do to make the built library (pure C) configuration-independent?
In theory you could build just one library if all the external headers for the library (ie the ones pulled in by the client) don’t use #ifdef _DEBUG (or any other macro that may be defined in a debug build but not a release build.
Consider a case like this:
In this case, if you were to link the library into a debug build of your own product then A will have a different size to the release build, which means you’re going to have some pretty horrendous memory corruption bugs to track down (been there…).
EDIT:
Forgot to mention, you should make your one configuration a Release configuration so that you don’t end up with any references to the debug CRT, and also so the library is optimised. As lsalamon points out, creating a pdb file and saving this along with your .lib file will be useful in the future for debugging.