title: a linker issue when learning static library
body: <p>I am currently studying linking chapter in CSAPP. 
  In this chapter there's a example showing how static library works: suppose we have two functions addvec.c and multvec.c ; and we use ar tool to combine the two functions into a library as follows:</p>
  
  <pre><code>unix&gt; gcc -c addvec.c multvec.c
  unix&gt; ar rcs libvector.a addvec.o multvec.o
  </code></pre>
  
  <p>To use the library, we write an application code main2.c as follows:</p>
  
  <pre><code>/* $begin main2 */
  /* main2.c */
  #include &lt;stdio.h&gt;
  #include "vector.h"
  
  int x[2] = {1, 2};
  int y[2] = {3, 4};
  int z[2];
  
  int main() 
  {
      addvec(x, y, z, 2);
      printf("z = [%d %d]\n", z[0], z[1]);
      return 0;
  }
  /* $end main2 */
  </code></pre>
  
  <p>To build the executable, we would compile and link the input files main2.o and libvector.a:</p>
  
  <pre><code>unix&gt; gcc -O2 -c main2.c
  unix&gt; gcc -static -o p2 main2.o ./libvector.a
  </code></pre>
  
  <p>however, when I tried the last step, my computer shows me this:</p>
  
  <pre><code>ld: library not found for -lcrt0.o
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>( I use macbook pro as my machine)
  I am not sure what is the problem here.</p>