How to circumvent LNK2005/LNK2006 (duplicate symbol)?

78 Views Asked by At

I have a situation where I have to link with two object files (for which I don't have the source code) that unfortunately duplicately defines symbols. I wonder if there's a reasonable way to circumvent this problem?

In another question there were the suggestion to use /FORCE to produce output anyway, however it was also mentioned that the use of /FORCE means that one have little control over the situation. Not only is which of the symbols to be used undefined it also would mean that unintentionally duplicate symbols would pass silently (which is likely to be an error).

What I would like is to tell the linker that I know that foo is defined in both bar.obj and baz.obj and it's supposed to disregard the one found in baz.obj. This way it should diagnose as an error if I were to define qux at two places in the codebase or even if I happen to accidently define foo in some other object file.

0

There are 0 best solutions below