title: googletest-ing several files
body: <p>I want to test my code for fibonacci sequence that is written in separate files(instructions!), but i don't know how to compile. </p>
  
  <p>fib.h:</p>
  
  <pre><code>#ifndef FIB_H
  #define FIB_H
  #include &lt;gtest/gtest.h&gt;
  
  
  class fib
  {
  public:
      int fibRec(int n);
  };
  
  TEST(testFib, firstTest)
  {
      fib fibnumber;
      EXPECT_EQ(55, fibnumber.fibRec(10));
      EXPECT_EQ(13, fibnumber.fibRec(8));
      EXPECT_EQ(89, fibnumber.fibRec(11));
      EXPECT_EQ(3, fibnumber.fibRec(5));
  }
  
  #endif // FIB_H
  </code></pre>
  
  <p>fib.cpp:</p>
  
  <pre><code>#include "fib.h"
  
  int fib::fibRec(int n)
  {
  
      if(n &lt;= 0) return 0;
      if(n == 1) return 1;
      else return(fibRec(n-1)+fibRec(n-2));
  
  }
  </code></pre>
  
  <p>main.cpp:</p>
  
  <pre><code>#include &lt;limits&gt;
  #include "fib.h"
  
  int main(int argc, char *argv[])
  {
     ::testing::InitGoogleTest(&amp;argc, argv);
     return RUN_ALL_TESTS();
  }
  </code></pre>
  
  <p>My <code>libgtest.a</code> is in <code>/home/me/gtest</code> and <code>include</code> is in <code>/home/me/gtest/gtest-1.7.0/include</code>.
  I tried to compile and run the test in terminal with g++ like this, but it didn't work</p>
  
  <pre><code>$ g++ -c fib.cpp
  $ g++ -c fib.h
  $ g++ -c main.cpp
  $ g++ -I/home/me/gtest/gtest-1.7.0/include -pthread main.cpp libgtest.a -o test_exe
  </code></pre>
  
  <p>What am I doing wrong or rather what should i add?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I tried <code>$ g++ -I/home/me/gtest/gtest-1.7.0/include -pthread main.cpp fib.cpp libgtest.a -o test_exe</code></p>
  
  <p>but I got an error</p>
  
  <pre><code>/tmp/ccTTfKeF.o:(.bss+0x0): multiple definition of `testFib_firstTest_Test::test_info_'
  /tmp/ccq6EExi.o:(.bss+0x0): first defined here
  /tmp/ccTTfKeF.o: In function `testFib_firstTest_Test::TestBody()':
  fib.cpp:(.text+0x0): multiple definition of `testFib_firstTest_Test::TestBody()'
  /tmp/ccq6EExi.o:main.cpp:(.text+0x0): first defined here
  collect2: error: ld returned 1 exit status
  </code></pre>