I am currently learning how to make and use MakeFiles for programs in C++. I have been able to create and run Makefiles for normal .cpp classes but I am having a problem with test classes. For testing I am using Gtest in Code::Blocks, and in my Test_A.cpp file in the "Linker Settings" I add:
/usr/lib/libgtest.a
/usr/lib/libgtest_main.a
and for the other linker options I put "-pthread". I know that in some way those libraries need to be added in the makefile, but I cannot figure how. I originally thought they need to be added in line 3, but everything I try returns thousands of lines of error of type:
undefined reference to `testing::Test::TearDown()
undefined reference to `testing::Test::~Test() etc....
My makefile:
1. all: Test
2. Test_A.o: Test_A B.h
3. g++ -c Test_A.cpp -o Test_A.o
4. Test: Test_A.o
5. g++ -o Test Test_A.o
6. clean:
7. rm -rf *o *~