title: undefined reference to symbol even when nm indicates that this symbol is present in the shared library
body: <p>What could be wrong here?  I have the following simple class:</p>
  
  <pre><code>#include  "libmnl/libmnl.h"
  
  int main() {
      struct mnl_socket *a = mnl_socket_open(12);
  }
  </code></pre>
  
  <p>And after running a simple <code>gcc</code> compile (<code>gcc -lmnl main.c</code>) I get the following errors:</p>
  
  <pre><code>/tmp/cch3GjuS.o: In function `main':
  main.c:(.text+0xe): undefined reference to `mnl_socket_open'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>Running nm on the shared library shows that it's actually found:</p>
  
  <pre><code>aatteka@aatteka-Dell1:/tmp$ nm -D /usr/lib/libmnl.so | grep mnl_socket_open
  0000000000001810 T mnl_socket_open
  </code></pre>
  
  <p>This is happening on Ubuntu 12.04. The <em>libmnl-dev</em> and <em>libmnl0</em> packages are installed. The <code>strace</code> output of <code>gcc</code> indicates that <code>ld</code> is using exactly that *.so file:</p>
  
  <pre><code>[pid 10988] stat("/usr/lib/gcc/x86_64-linux-gnu/4.6/libmnl.so", 0x7fff2a39b470) = -1 ENOENT (No such file or directory)
  [pid 10988] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/libmnl.so", O_RDONLY) = -1 ENOENT (No such file or directory)
  [pid 10988] stat("/usr/lib/gcc/x86_64-linux-gnu/4.6/libmnl.a", 0x7fff2a39b4d0) = -1 ENOENT (No such file or directory)
  [pid 10988] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/libmnl.a", O_RDONLY) = -1 ENOENT (No such file or directory)
  [pid 10988] stat("/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libmnl.so", 0x7fff2a39b470) = -1 ENOENT (No such file or directory)
  [pid 10988] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libmnl.so", O_RDONLY) = -1 ENOENT (No such file or directory)
  [pid 10988] stat("/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libmnl.a", 0x7fff2a39b4d0) = -1 ENOENT (No such file or directory)
  [pid 10988] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libmnl.a", O_RDONLY) = -1 ENOENT (No such file or directory)
  [pid 10988] stat("/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmnl.so", {st_mode=S_IFREG|0644, st_size=18608, ...}) = 0
  [pid 10988] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmnl.so", O_RDONLY) = 7
  </code></pre>