Saturday, December 12, 2015

Google Test Framework

The place you get your stuff :
http://www.yolinux.com/TUTORIALS/Cpp-GoogleTest.html

Couple of the things one should remember for compilation:

If you make cribs for
makefile:7: *** missing separator.  Stop

Go to the makefile line in which there is a problem and split the line like below.
Original:
testAll: $(OBJS)
    $(CXX) Main_TestAll.cpp $(CXXFLAGS) $(INCS) -o testAll $(OBJS)

Fixed :

testAll: $(OBJS);\
$(CXX) Main_TestAll.cpp $(CXXFLAGS) $(INCS) -o testAll $(OBJS)

Again on compilation of the test framwork, if it cribs for

vagrant@guca-csa-dev:~/gen_work/gtf/gtest-1.7.0/test/src$ make
\
g++ -g -L/opt/gtest/lib -lgtest -lgtest_main -lpthread -I./ -I../../src -I/opt/gtest/include -o testAll  Main_TestAll.cpp ../../src/Addition.o Addition_Test.o ../../src/Multiply.o Multiply_Test.o
/usr/bin/ld: Addition_Test.o: undefined reference to symbol '_ZN7testing8internal9EqFailureEPKcS2_RKSsS4_b'
/opt/gtest/lib/libgtest.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [testAll] Error 1

Solution:
Go to makefile and place the .cpp file before header and library inclusion.

something like this below.
testAll: $(OBJS);\
$(CXX) Main_TestAll.cpp $(CXXFLAGS) $(INCS) -o testAll $(OBJS


No comments: