title: Undefined References After Linking Against Static Library
body: <p>I wrote a simple program to test if xdotool can fulfill my requirements. (Well, not really. My first step is to make sure if I can make calls into the xdotool library.)</p>
  
  <pre><code>#include &lt;xdo.h&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main(){
      cout &lt;&lt; xdo_version() &lt;&lt; endl;
      xdo_new(NULL);
      return 0;
  }
  </code></pre>
  
  <p>However, when I compile this with <code>g++ -o a main.cpp libxdo.a -lXtst -lX11 -lXinerama -I ../test/xdotool-2.20110530.1</code>, I get the following error message:</p>
  
  <pre><code>/tmp/ccW95RQx.o: In function `main':
  main.cpp:(.text+0x5): undefined reference to `xdo_version()'
  main.cpp:(.text+0x29): undefined reference to `xdo_new(char*)'
  collect2: error: ld returned 1 exit status
  make: *** [sendkey] Error 1
  </code></pre>
  
  <p>I didn't use the development packages from apt-get install because it installs a dynamic library. So, I did a apt-get source and built the library myself. I verified that xdo_version and xdo_new are defined functions in the static library by performing the following commands:</p>
  
  <pre><code>$ nm libxdo.a | grep xdo_version
  00000000000002b0 T xdo_version
  $ nm libxdo.a | grep xdo_new
  0000000000004070 T xdo_new
  0000000000003c90 T xdo_new_with_opened_display
  </code></pre>
  
  <p>If I am not mistaken, the <code>T</code> besides the symbol's name means that the function is defined.</p>
  
  <p>In conclusion, I'm trying to get the above C++ snippet to compile successfully and statically linking against xdotool but encountered some errors as stated above.</p>