title: How to compile Boost multithreaded program?
body: <p>I installed boost library. Everything is going OK without multithreading. 
  How do i compile this test program ?</p>
  
  <pre><code>#include &lt;boost/thread/thread.hpp&gt;
  #include &lt;iostream&gt;
  using namespace std; 
  
  void hello_world() {
    cout &lt;&lt; "I'm new thread!" &lt;&lt; endl;
  }
  
  int main(int argc, char* argv[]) {     
    boost::thread my_thread(&amp;hello_world);
    my_thread.join();
  
    return 0;
  }
  </code></pre>
  
  <p>I used: <code>g++ -I/home/user/boost/include testc.cpp</code></p>
  
  <p>but g++ show me:</p>
  
  <pre><code>/tmp/ccQtBeSf.o: In function `main':
  testc.cpp:(.text+0x5a): undefined reference to `boost::thread::join()'
  /tmp/ccQtBeSf.o: In function `__static_initialization_and_destruction_0(int, int)':
  testc.cpp:(.text+0xd5): undefined reference to `boost::system::generic_category()'
  testc.cpp:(.text+0xdf): undefined reference to `boost::system::generic_category()'
  testc.cpp:(.text+0xe9): undefined reference to `boost::system::system_category()'
  /tmp/ccQtBeSf.o: In function `boost::thread_exception::thread_exception(int, char const*)':
  testc.cpp:(.text._ZN5boost16thread_exceptionC2EiPKc[_ZN5boost16thread_exceptionC5EiPKc]+0x7): undefined reference to `boost::system::system_category()'
  /tmp/ccQtBeSf.o: In function `boost::detail::thread_data_base::thread_data_base()':
  testc.cpp:(.text._ZN5boost6detail16thread_data_baseC2Ev[_ZN5boost6detail16thread_data_baseC5Ev]+0x1a): undefined reference to `vtable for boost::detail::thread_data_base'
  /tmp/ccQtBeSf.o: In function `boost::thread::~thread()':
  testc.cpp:(.text._ZN5boost6threadD2Ev[_ZN5boost6threadD5Ev]+0xe): undefined reference to `boost::thread::detach()'
  /tmp/ccQtBeSf.o: In function `boost::thread::thread&lt;void (*)()&gt;(void (*)(), boost::disable_if&lt;boost::is_convertible&lt;void (*&amp;)(), boost::detail::thread_move_t&lt;void (*)()&gt; &gt;, boost::thread::dummy*&gt;::type)':
  testc.cpp:(.text._ZN5boost6threadC2IPFvvEEET_NS_10disable_ifINS_14is_convertibleIRS4_NS_6detail13thread_move_tIS4_EEEEPNS0_5dummyEE4typeE[_ZN5boost6threadC5IPFvvEEET_NS_10disable_ifINS_14is_convertibleIRS4_NS_6detail13thread_move_tIS4_EEEEPNS0_5dummyEE4typeE]+0x23): undefined reference to `boost::thread::start_thread()'
  /tmp/ccQtBeSf.o: In function `boost::detail::thread_data&lt;void (*)()&gt;::~thread_data()':
  testc.cpp:(.text._ZN5boost6detail11thread_dataIPFvvEED2Ev[_ZN5boost6detail11thread_dataIPFvvEED5Ev]+0x16): undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
  /tmp/ccQtBeSf.o:(.rodata._ZTIN5boost6detail11thread_dataIPFvvEEE[typeinfo for boost::detail::thread_data&lt;void (*)()&gt;]+0x8): undefined reference to `typeinfo for boost::detail::thread_data_base'
  collect2: ld returned 1 exit status
  </code></pre>