1. Get the googletest framework
Or get it by hand. I guess I won't maintain this little How-to, so if you stumbled upon it and the links are outdated, feel free to edit it.
2. Unpack and build google test
tar xf release-1.7.0.tar.gz
cmake -DBUILD_SHARED_LIBS=ON .
3. "Install" the headers and libs on your system.
This step might differ from distro to distro, so make sure you copy the headers and libs in the correct directory. I accomplished this by checking where Debians former gtest libs were located. But I'm sure there are better ways to do this. Note:
make install is dangerous and not supported
$ sudo cp -a include/gtest /usr/include
$ sudo cp -a libgtest_main.so libgtest.so /usr/lib/
4. Update the cache of the linker
... and check if the GNU Linker knows the libs
$ sudo ldconfig -v | grep gtest
If the output looks like this:
libgtest.so.0 -> libgtest.so.0.0.0
libgtest_main.so.0 -> libgtest_main.so.0.0.0
, everything is fine.
gTestframework is now ready to use. Just don't forget to link your project against the library by setting
-lgtest as linker flag and optionally, if you did not write your own test mainroutine, the explicit
From here on you might want to go to Googles documentation about the framework to learn how it works. Happy coding!
Edit: This works for OS X too! See "How to properly setup googleTest on OS X"