title: what is the difference between ranlib, ar, and ld for making libraries
body: <p>To make libraries in c++/unix from *.o files, I have noticed two different ways in my project (legacy code):</p>
  
  <pre><code>ar qc libgraphics.a *.o
  ranlib libgraphics.a
  </code></pre>
  
  <p>and</p>
  
  <pre><code>ld -r -o libgraphics.a *.o
  </code></pre>
  
  <p>What is the difference between the two approaches, and which is to be used for what purpose?</p>