Note that there are some explanatory texts on larger screens.

plurals
  1. POLink libraries with dependencies in Visual C++ without getting LNK4006
    text
    copied!<p>I have a set of statically-compiled libraries, with fairly deep-running dependencies between the libraries. For example, the executable X uses libraries A and B, A uses library C, and B uses libraries C and D:</p> <pre><code>X -&gt; A A -&gt; C X -&gt; B B -&gt; C B -&gt; D </code></pre> <p>When I link X with A and B, I don't want to get errors if C and D were not also added to the list of libraries&mdash;the fact that A and B use these libraries internally is an implementation detail that X should not need to know about. Also, when new dependencies are added anywhere in the dependency tree, the project file of any program that uses A or B would have to be reconfigured. For a deep dependency tree, the list of required libraries can become really long and hard to maintain.</p> <p>So, I am using the "Additional Dependencies" setting of the Librarian section in the A project, adding C.lib. And in the same section of B's project, I add C.lib and D.lib. The effect of this is that the librarian bundles C.lib into A.lib, and C.lib and D.lib into B.lib.</p> <p>When I link X, however, both A.lib and B.lib contain their own copy of C.lib. This leads to tons of warnings along the lines of</p> <blockquote> <p>A.lib(c.obj) : warning LNK4006 "symbol" (_symbol) already defined in B.lib(c.obj); second definition ignored.</p> </blockquote> <p>How can I accomplish this without getting warnings? Is there a way to simply disable the warning, or is there a better way?</p> <p><strong>EDIT</strong>: I have seen more than one answer suggesting that, for the lack of a better alternative, I simply disable the warning. Well, this is part of the problem: I don't even know how to disable it!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload