Gtest: Undefined References

From linker errors it is obvious that you did not link gtest library to your test program.

See Primer:

To write a test program using Google Test, you need to compile Google Test into a library and link your test with it. ...

Just see this doc for details about your compiler and system.


Your setup looks to be almost correct. However, you're needing to have 2 separate main functions; one for the real executable Proj2 and another with the gtest includes and functions for the test executable unit-test.

You could do this by having 2 different main.cpp files, say main.cpp and test_main.cpp. The one you've shown would be test_main.cpp, and would be included in the add_executable(unit-test ... command.

Your new main.cpp would have no references to gtest, either includes or functions.