views:

111

answers:

3

I have an application I'm working on that uses two third party libraries, each with pre-compiled libs and dlls, one of which provides necessary .lib files for both debug and release builds (A[d].lib) and the other which provides only .lib files for release builds (B.lib). Compiling in Release mode (using MSVC9) works fine, however attempting to compile in debug mode fails because third party A requires LIBCMTD.lib (or MSVCRTD.lib) while third party B requires LIBCMT.lib (or MSVCRT.lib). Can I work around this or am I stuck debugging in release mode?

Thanks

+1  A: 

Try passing /NODEFAULTLIB:LIBCMT to the linker.

Fredrik Ullner
With the flag you mention I instead get `error LNK2001: unresolved external symbol __invalid_parameter_noinfo` (because of `B` which requires it).
Geoff
Google seem to give hits to using `_SECURE_SCL=0` in the preprocessor to fix that.
Fredrik Ullner
I tried various combinations of other solutions involving _SECURE_SCL to no avail.
Geoff
+1  A: 

I am not sure it can be done directly with static libraries. I suggest you package library B into a dynamic library, then use this new B' library. Your problems will have disappeared.

Benoît
That'd definitely be a good solution for production software once everything is ironed out, for now that seems like too much trouble, thanks though!
Geoff
+3  A: 

Do you want full debug mode, or do you just want to be able to debug? If the later is the case, just go to the linker options, and turn on the generation of symbolic information (.pdb). This way you can use the debugger in your own code, step through the lines, and look at variables. If you get annoyed by the changes in control flow that the optimizers create, you can go to the compiler options, and turn off optimizations. This way you get to use the debugger AND build in release mode. Once you're happy with your code, you just change the settings back to creating optimized code.

Carsten Kuckuk
Actually, I'd start from the opposite end: just take the existing debug configuration, and link against LIBCMT.lib, A.lib and B.lib. But the point is the same: create an executable that's not optimized, has debug info, but links against release libs.
MSalters
@Carsten: Yes I'd like full debug, in the end I opted for your and MSalters (+1!) approach. Thanks for the advice!
Geoff