title: Issues with ld and static library "undefined reference to"
body: <p>This one is a little embarassing. I know what's going on but not why. I get an "undefined reference to" error which means the linker (ld) is not putting the code from the library I've created.</p>
  
  <p>I'm currently fooling around with Zed A. Shaw <a href="http://c.learncodethehardway.org/">"Learn C the Hard Way"</a> course. I'm trying to finish exercise 32, but I keep getting the same error. </p>
  
  <p>In the book you develop a make file that runs the following command:</p>
  
  <pre><code>cc -g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG  build/liblcthw.a \
      tests/list_tests.c   -o tests/list_tests
  </code></pre>
  
  <p>where -g is to enable debug info, -Wall is to enable "all" warnings, -Wextra is to enable more warnings, -Isrc to include src directory to the library directory, -o tests/list_tests is to produce an output with that name in that directory, -DNDEBUG to enable a variable from the code, -O2 for level 2 optimization (whatever that means) and build/liblcthw.a to include that library (the one that is getting build). The rest I have no clue what they do.</p>
  
  <p>If I got it right there's a list.c in the src directory that creates an object list.o. This object is later include in the lib via ar and ranlib. So calling the header list.h should make ld to look in build/liblcthw.a for list.o. The thing is ld is not reading build/liblcthw.a for some reason. So i get this undefined reference to error.</p>
  
  <p>I have tried to contact Zed but he's a busy man apparently. So I'm hoping to get help here. Tell me if i need to add more info about the issue. <a href="http://dl.dropbox.com/u/105216643/liblcthw.tar.bz2">Here's</a> a link to the whole library so far.</p>
  
  <p>I hope someone can help me.</p>