title: gtest - undefined reference to `testing::InitGoogleTest(int*, char**)'
body: <p>I'm trying to create makefile and compile simple example of <code>gtest</code> but I get the error:</p>
  
  <blockquote>
    <p>g++ main.o  -o exampleOutput main.o: In function <code>main':
    main.cpp:(.text+0x1e): undefined reference to
    </code>testing::InitGoogleTest(int*, char**)' collect2: error: ld returned 1
    exit status make: *** [output] Error 1</p>
  </blockquote>
  
  <p>This the main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "gtest/gtest.h"
  
  using namespace std;
  
  int main(int argc, char **argv)
  {
      cout &lt;&lt; "This is test" &lt;&lt; endl;
      testing::InitGoogleTest(&amp;argc, argv);
      return 0;
  }
  </code></pre>
  
  <p>This is the makefile:</p>
  
  <pre><code>INCLUDE = -I/usr/include/
  LIBPATH = -L/usr/lib/
  
  output: main.o 
      g++ main.o  -o exampleOutput
  
  main.o: main.cpp
      g++ -c main.cpp $(INCLUDE)  $(LIBPATH) -lgtest -lgtest_main  -pthread
  </code></pre>
  
  <p>The header files (of Gtest) are located in <code>/usr/include/gtest</code>
  and the lib files are located in <code>/usr/lib</code>.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks.</p>