I'm using VC10 (but I guess this applies to VC9, VC10 and VC11). In short, I want to compile a release library, ship it and allow users to be able to link to that library when making a debug or release build of their application. Annoyingly I keep getting the LNK4204 error, for example:
mylib.lib(an_object_in_my_lib.obj) : warning LNK4204: '[PATH TO USER APPLICATION INTERMEDIATE DIRECTORY]\vc100.pdb' is missing debugging information for referencing module; linking object as if no debug info
Fine. I understand what this is saying. My initial reaction was "well, it's going to be trivial to turn this off". However I can find no way of preventing this. Things that have surprised me are:
- I can't find any option in the library project setting to compile without debug info (even in release!) - and by God I could swear there is a way!
- I can't find any option in the user application project settings to instruct the linker that I know there's no debugging info and it should just get on and do what it's told!
Is there any good solution to this? Presumably it's not uncommon to want to link to a library with no debug info but produce debug info for the binary I'm creating? What about linking to kernel libraries and crts, surely that's exactly what happens? I can't believe I've never found this problem before, it seems to obvious (can you tell I'm exasperated!).
FYI, before people say it, I really don't want to ship release libs with debugging info as I want to minimize the risk of reverse engineering. I know that some people will say that you'll regret it when a user gets a bug and you have no pdb info, but trust me when I say I don't care about that.
Update:
I believe I've got around the problem but I'm not entirely sure why it works. Definitely need to look into this some more. But in short, I can (and in fact need to) build with VC9. Note that VC9 actually gives you an extra option of "Disabled" for "Debug Information Format", which doesn't appear in VC10; this may explain some of my confusion.
Now the "solution" seemed to be to create a debug version of the library (I'm fine with that) but keep debug info "Disabled". When I do this I get no complaints. It's quite strange as in both cases there's no debug info (the cases being linking debug to release and debug to debug), however when linking to the debug lib I get no warnings. It's a bit of a mystery so far. If I get time I'll investigate it further. Maybe I'm missing something!