title: Boost thread error: undefined reference
body: <pre><code>#include &lt;boost/thread/thread.hpp&gt;
  #include &lt;iostream&gt;
  
  void hello()
  {
    std::cout &lt;&lt;
      "Hello world, I'm a thread!"
      &lt;&lt; std::endl;
  }
  
  int main(int argc, char* argv[])
  {
    boost::thread thrd(&amp;hello);
    thrd.join();
    return 0;
  }
  </code></pre>
  
  <p>I ran tried to compile this program, and got these errors:</p>
  
  <pre><code>/usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to
     `boost::thread_resource_error::thread_resource_error()'
  /usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to 
     `boost::thread_resource_error::~thread_resource_error()'
  /usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to 
     `typeinfo for boost::thread_resource_error'
  ./src/thread.o: In function `condition_variable':
  /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: 
    undefined reference to `boost::thread_resource_error::thread_resource_error()'
  /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: 
    undefined reference to `boost::thread_resource_error::~thread_resource_error()'
  /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: \
    undefined reference to `typeinfo for boost::thread_resource_error'
  ./src/thread.o: In function `thread_data_base':
  /usr/include/boost/thread/pthread/thread_data.hpp:54: 
    undefined reference to `vtable for boost::detail::thread_data_base'
  ./src/thread.o: In function `thread&lt;void (*)()&gt;':
  /usr/include/boost/thread/detail/thread.hpp:188: 
    undefined reference to `boost::thread::start_thread()'
  ./src/thread.o: In function `~thread_data':
  /usr/include/boost/thread/detail/thread.hpp:40: 
    undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
  /usr/include/boost/thread/detail/thread.hpp:40: undefined reference to 
    `boost::detail::thread_data_base::~thread_data_base()'
  </code></pre>
  
  <p>Can any one tell me why i am getting this error?</p>