I am currently learning how to create and use MakeFiles for C ++ programs. I was able to create and run a Makefile for regular .cpp classes, but I have a problem with test classes. For testing, I use Gtest in Code :: Blocks, and in my Test_A.cpp file in the "Linker Settings" add:
/usr/lib/libgtest.a
/usr/lib/libgtest_main.a
and for other linker options I will put "-pthread". I know that somehow these libraries should be added to the makefile, but I cannot figure out how to do this. Initially, I thought they needed to be added to line 3, but all I'm trying is returning thousands of lines of error like:
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 *~
source
share