title: Resolving circular dependencies by linking the same library twice?
body: <p>We have a code base broken up into static libraries.  Unfortunately, the libraries have circular dependencies; e.g., <code>libfoo.a</code> depends on <code>libbar.a</code> and vice-versa.</p>
  
  <p>I know the "correct" way to handle this is to use the linker's <code>--start-group</code> and <code>--end-group</code> options, like so:</p>
  
  <pre><code>g++ -o myApp -Wl,--start-group -lfoo -lbar -Wl,--end-group
  </code></pre>
  
  <p>But in our existing Makefiles, the problem is typically handled like this:</p>
  
  <pre><code>g++ -o myApp -lfoo -lbar -lfoo
  </code></pre>
  
  <p>(Imagine this extended to ~20 libraries with complex interdependencies.)</p>
  
  <p>I have been going through our Makefiles changing the second form to the first, but now my co-workers are asking me why...  And other than "because it's cleaner" and a vague sense that the other form is risky, I do not have a good answer.</p>
  
  <p>So, can linking the same library multiple times <em>ever</em> create a problem?  For example, could the link fail with multiply-defined symbols if the same .o gets pulled in twice?  Or is there any risk we could wind up with two copies of the same static object, creating subtle bugs?</p>
  
  <p>Basically, I want to know if there is any possibility of link-time or run-time failures from linking the same library multiple times; and if so, how to trigger them.  Thanks.</p>