title: g++: In what order should static and dynamic libraries be linked?
body: <p>Let's say we got a main executable called "my_app" and it uses several other libraries: 3 libraries are linked statically, and other 3 are linked dynamically.
  In which order should they be linked against "my_app"?</p>
  
  <p>But in which order should these be linked?</p>
  
  <p>Let's say we got libSA (as in Static A) which depends on libSB, and libSC which depends on libSB:</p>
  
  <pre><code>libSA -&gt; libSB -&gt; libSC
  </code></pre>
  
  <p>and three dynamic libraries:<code>libDA -&gt; libDB -&gt; libDC</code> (<code>libDA</code> is the basic, <code>libDC</code> is the highest)</p>
  
  <p>in which order should these be linked? the basic one first or last?</p>
  
  <pre><code>g++ ... -g libSA libSB libSC -lDA -lDB -lDC -o my_app
  </code></pre>
  
  <p>seems like the currect order, but is that so? what if there are dependencies between any dynamic library to a static one, or the other way?</p>