title: Ordering of object files and libraries in static linking
body: <p>I've created a simple static library <code>libvec.a</code> with AR tool from simple <code>addv.o</code> and <code>multo.o</code>. The object file <code>addv.o</code> contains 1 function symbol (<code>addvec</code>) and <code>multo.o</code> contains 1 function (<code>multvec</code>). I have also written a simple program to test it (<code>driver.c</code> which adds 2 vectors and uses <code>addvec</code> function from the library; also it has included <code>vector.h</code> that defines the function prototypes).  And then  I compiled it with</p>
  
  <pre><code>gcc -static driver.o ./libvec.a
  </code></pre>
  
  <p>and everything went okay. But at first I tried to compile it with</p>
  
  <pre><code>gcc -static ./libvec.a driver.o
  </code></pre>
  
  <p>and I got an error:</p>
  
  <pre><code>undefined reference to 'addvec'
  </code></pre>
  
  <p>I'm wondering why I got an error when I specified the library first? Should the ordering matter?</p>