title: Why am I getting undefined reference to pthread_mutexattr_settype?
body: <p>I am trying to compile and link a sample file from the Novell LDAP C SDK but the link is failing due to 3 unresolved symbols in the <code>pthread</code> library.  I am using gcc 4.8.1 on Ubuntu 13.10 (Saucy).  I have properly included the <code>pthread</code> library as the last library on the command line, but these particular symbols are still not being resolved.</p>
  
  <pre><code>$ gcc -Wl,-trace-symbol=pthread_mutexattr_settype -Wl,-trace-symbol=pthread_mutexattr_init   -Wl,-trace-symbol=pthread_mutex_trylock  -o search search.o -L../lib -lldapsdk -lpthread
  
  ../lib/libldapsdk.so: reference to pthread_mutexattr_settype&lt;br&gt;
  ../lib/libldapsdk.so: reference to pthread_mutexattr_init&lt;br&gt;
  ../lib/libldapsdk.so: reference to pthread_mutex_trylock&lt;br&gt;
  /lib/i386-linux-gnu/libpthread.so.0: definition of pthread_mutexattr_settype&lt;br&gt;
  /lib/i386-linux-gnu/libpthread.so.0: definition of pthread_mutexattr_init&lt;br&gt;
  /lib/i386-linux-gnu/libpthread.so.0: definition of pthread_mutex_trylock&lt;br&gt;
  ../lib/libldapsdk.so: undefined reference to pthread_mutexattr_settype&lt;br&gt;
  ../lib/libldapsdk.so: undefined reference to pthread_mutex_trylock&lt;br&gt;
  ../lib/libldapsdk.so: undefined reference to pthread_mutexattr_init&lt;br&gt;
  collect2: error: ld returned 1 exit status
  
  $ readelf --all  /lib/i386-linux-gnu/libpthread.so.0|grep pthread_mutexattr_settype&lt;br&gt;
     114: 00009d90    36 FUNC    GLOBAL DEFAULT   13 pthread_mutexattr_settype@@GLIBC_2.1&lt;br&gt;
     493: 00009d90    36 FUNC    GLOBAL DEFAULT   13 pthread_mutexattr_settype
  </code></pre>