title: Installing GTest and GMock
body: <p>I have installed GTest and GMock on my Ubuntu 17.04 box. Broadly speaking installed as follows;</p>
  
  <p>sudo apt-get install libgtest-dev
  cmake CMakeLists.txt
  make</p>
  
  <p>I then sym linked the libraries creaetd in /usr/src in /usr/lib. (ie link in /usr/lib points to /usr/src)</p>
  
  <p>I then did the same for GMock</p>
  
  <p>sudo apt-get install -y google-mock</p>
  
  <p>then cmake and make as above
  Libraries sym linked as before.</p>
  
  <p>I have created the following CMakeLists.txt</p>
  
  <pre><code>project(chapterFirstExample)
  cmake_minimum_required(VERSION 2.6)
  
  include_directories(/usr/include)
  link_directories(/usr/lib)
  add_definitions(-std=c++0x)
  set(CMAKE_CXX_FLAGS "${CMAXE_CXX_FLAGS} -Wall")
  
  set(sources
     main.cpp
     SoundexTest.cpp)
  add_executable(tddTest ${sources})
  target_link_libraries(tddTest pthread)
  target_link_libraries(tddTest gmock)
  target_link_libraries(tddTest gtest)
  </code></pre>
  
  <p>And have two source files</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include "gmock/gmock.h"
  
  int main(int argc, char** argv) {
     testing::InitGoogleMock(&amp;argc, argv);
     return RUN_ALL_TESTS();
  }
  </code></pre>
  
  <p>SoundexTest.cpp</p>
  
  <pre><code>class Soundex
  {
  };
  
  #include "gmock/gmock.h"
  
  TEST(SoundexEncoding, RetainsSoleLetterOfOneLetterWord)
  {
          Soundex soundex;
  }
  </code></pre>
  
  <p>(I am working through Jeff Langr's Modern C++ Programming with Test Driven Development book)</p>
  
  <p>I run cmake on my CmakeLists.txt file, which runs without error. When I run make though I get this;</p>
  
  <pre><code>[ 33%] Linking CXX executable tddTest
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgmock.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal&lt;testing::TestPartResultReporterInterface*&gt;::~ThreadLocal()':
  gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED2Ev[_ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED5Ev]+0x24): undefined reference to `pthread_getspecific'
  gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED2Ev[_ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED5Ev]+0x39): undefined reference to `pthread_key_delete'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgmock.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal&lt;std::vector&lt;testing::internal::TraceInfo, std::allocator&lt;testing::internal::TraceInfo&gt; &gt; &gt;::~ThreadLocal()':
  gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED2Ev[_ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED5Ev]+0x24): undefined reference to `pthread_getspecific'
  gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED2Ev[_ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED5Ev]+0x39): undefined reference to `pthread_key_delete'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgmock.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal&lt;std::vector&lt;testing::internal::TraceInfo, std::allocator&lt;testing::internal::TraceInfo&gt; &gt; &gt;::GetOrCreateValue() const':
  gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv]+0x25): undefined reference to `pthread_getspecific'
  gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv]+0x88): undefined reference to `pthread_setspecific'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgmock.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal&lt;testing::TestPartResultReporterInterface*&gt;::CreateKey()':
  gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE9CreateKeyEv[_ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE9CreateKeyEv]+0x27): undefined reference to `pthread_key_create'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgmock.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal&lt;std::vector&lt;testing::internal::TraceInfo, std::allocator&lt;testing::internal::TraceInfo&gt; &gt; &gt;::CreateKey()':
  gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE9CreateKeyEv[_ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE9CreateKeyEv]+0x27): undefined reference to `pthread_key_create'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgmock.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal&lt;testing::TestPartResultReporterInterface*&gt;::GetOrCreateValue() const':
  gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv]+0x25): undefined reference to `pthread_getspecific'
  gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv]+0x88): undefined reference to `pthread_setspecific'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgmock.a(gmock-all.cc.o): In function `testing::internal::ThreadLocal&lt;testing::Sequence*&gt;::CreateKey()':
  gmock-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_8SequenceEE9CreateKeyEv[_ZN7testing8internal11ThreadLocalIPNS_8SequenceEE9CreateKeyEv]+0x27): undefined reference to `pthread_key_create'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgmock.a(gmock-all.cc.o): In function `testing::internal::ThreadLocal&lt;testing::Sequence*&gt;::GetOrCreateValue() const':
  gmock-all.cc:(.text._ZNK7testing8internal11ThreadLocalIPNS_8SequenceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_8SequenceEE16GetOrCreateValueEv]+0x25): undefined reference to `pthread_getspecific'
  gmock-all.cc:(.text._ZNK7testing8internal11ThreadLocalIPNS_8SequenceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_8SequenceEE16GetOrCreateValueEv]+0x88): undefined reference to `pthread_setspecific'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgmock.a(gmock-all.cc.o): In function `testing::internal::ThreadLocal&lt;testing::Sequence*&gt;::~ThreadLocal()':
  gmock-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_8SequenceEED2Ev[_ZN7testing8internal11ThreadLocalIPNS_8SequenceEED5Ev]+0x24): undefined reference to `pthread_getspecific'
  gmock-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_8SequenceEED2Ev[_ZN7testing8internal11ThreadLocalIPNS_8SequenceEED5Ev]+0x39): undefined reference to `pthread_key_delete'
  collect2: error: ld returned 1 exit status
  CMakeFiles/tddTest.dir/build.make:120: recipe for target 'tddTest' failed
  make[2]: *** [tddTest] Error 1
  CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/tddTest.dir/all' failed
  make[1]: *** [CMakeFiles/tddTest.dir/all] Error 2
  Makefile:83: recipe for target 'all' failed
  make: *** [all] Error 2
  </code></pre>
  
  <p>I am new to cmake, and very rusty on make. This output though makes me feel thought that I have not built GTest or GMock correctly. Can anyone give some pointers please. (No pun intended)</p>
  
  <p>Thanks</p>