title: How to compile a gtest cpp file?
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</p>
  
  <pre><code>g++ -lgtest -lgtest_main -lpthread test1.cpp 
  </code></pre>
  
  <p>just to see yet another unhelpful error message: </p>
  
  <pre><code>/usr/bin/ld: /tmp/ccQlmghI.o: undefined reference to symbol '_ZN7testing8internal9EqFailureEPKcS2_RKSsS4_b'
  /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: error adding symbols: DSO missing from command line
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>How can I fix this? Or is there another unittest framework which can be used in a SIMPLE way, with a working example? </p>
  
  <p>The same question has been asked <a href="https://stackoverflow.com/questions/26232237/google-testing-missing-dso">here</a>, but without an answer. </p>