For more information watch this video
$ git clone https://github.com/google/googletest.git
$ cd googletest
$ cmake -DBUILD_SHARED_LIBS=ON .
$ make
$ sudo cp -a include/gtest /usr/include
$ sudo cp -a libgtest_main.so libgtest.so /usr/lib/
$ sudo ldconfig -v
And now compile any program that uses Google test with
'-lgtest'
flag.
Source: http://stackoverflow.com/questions/13513905/how-to-setup-googletest-as-a-shared-library-on-linux