title: What are the correct link options to use std::thread in GCC under linux?
body: <p>Hi I am trying to use <code>std::thread</code> with G++. Here is my test code</p>
  
  <pre><code>#include &lt;thread&gt;
  #include &lt;iostream&gt;
  
  int main(int, char **){
      std::thread tt([](){ std::cout&lt;&lt;"Thread!"&lt;&lt;std::endl; });
      tt.join();
  }
  </code></pre>
  
  <p>It compiles, but when I try to run it the result is:</p>
  
  <pre><code>terminate called after throwing an instance of 'std::system_error'
    what():  Operation not permitted 
  Aborted
  </code></pre>
  
  <p>My compiler version:</p>
  
  <pre><code>$ g++ --version
  g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
  Copyright (C) 2011 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  </code></pre>
  
  <p>What is wrong with my test code?</p>
  
  <p>UPDATE: I use the following command line to compile and run my code.</p>
  
  <pre><code>$ g++ -std=c++0x test.cpp
  $ ./a.out
  </code></pre>
  
  <p>and I tried</p>
  
  <pre><code>$ g++ -std=c++0x -lpthread test.cpp
  $ ./a.out
  </code></pre>
  
  <p>still the same.</p>