title: undefined reference to `pthread_key_create'; argument order does not fix issue
body: <p>On Ubuntu Linux, I have been following the <code>gtest</code> instructions given <a href="https://stackoverflow.com/questions/13513905/how-to-properly-setup-googletest-on-linux">here</a> to install <code>gtest</code> with manually copying the header files and libraries to <code>/usr/include</code> and <code>/usr/lib</code>, respectively.</p>
  
  <p>I then tried to compile the following code (<code>test1.cpp</code>)</p>
  
  <pre><code>#include &lt;gtest/gtest.h&gt;
  TEST(MathTest, TwoPlusTwoEqualsFour) {
      EXPECT_EQ(2 + 2, 4);
  }
  
  int main(int argc, char **argv) {
      ::testing::InitGoogleTest( &amp;argc, argv );
      return RUN_ALL_TESTS();
  }
  </code></pre>
  
  <p>with the following command (as suggested <a href="https://stackoverflow.com/questions/27091412/how-to-compile-a-gtest-cpp-file#27091541">here</a> and <a href="https://stackoverflow.com/questions/11482445/undefined-reference-to-pthread-key-create">here</a>) </p>
  
  <pre><code>g++ -Wall -g -pthread test1.cpp -lgtest_main  -lgtest -lpthread  
  </code></pre>
  
  <p>just to see the following errors: </p>
  
  <pre><code>/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: undefined reference to `pthread_key_create'
  /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: undefined reference to `pthread_getspecific'
  /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: undefined reference to `pthread_key_delete'
  /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: undefined reference to `pthread_setspecific'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>The generic answer was about the order of the arguments to <code>g++</code>. However, I think I have tried every combinatoric order of the arguments <code>-lpthread</code> (with and without the <code>l</code>), <code>-lgtest</code> and <code>-lgtest_main</code>. I always get the same errors. </p>
  
  <p>I do not think the order is the problem. It must be something else. Anyone any ideas?</p>