pradeep
pradeep

Reputation: 31

tdd using cpputest make errors in ubuntu 14.04

I am trying to learn cpputest, so went to the cpputest manual and copied the below code in my ubuntu 14.04lts laptop, and tried to make. I am new to make files, and I got a bunch of errors - how can I correct my code?

#include "CppUTest/TestHarness.h"
#include "CppUTest/TestOutput.h"

TEST_GROUP(FirstTestGroup)
{
};

TEST(FirstTestGroup, FirstTest)
{
    FAIL("Fail me!");
}

TEST(FirstTestGroup, SecondTest)
{
   STRCMP_EQUAL("hello", "world");
   LONGS_EQUAL(1, 2);
   CHECK(false);
}

That is test.cpp, and i have main like below named test_main.cpp

#include "CppUTest/CommandLineTestRunner.h"

int main(int argc, char** argv)
{
   return CommandLineTestRunner::RunAllTests(argc, argv);
}

The make file is:

all: test
export CPPUTEST_HOME=/usr/share/cpputest
CPPFLAGS += -I$(CPPUTEST_HOME)/include 
LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt

test: test_main.o test.o
    g++ -o mytest test.o test_main.o
test_main.o: test_main.cpp 
    g++ -c test_main.cpp $(CPPFLAGS) 
test.o: test.cpp 
    g++ -c test.cpp  $(CPPFLAGS) $(LD_LIBRARIES)
    #g++ -C -o test_main.o test_main.cpp test.o test.cpp $(CPPFLAGS) 
    #g++ -o mytest tet_main.o test.o $(LD_LIBRARIES)

clean:
    rm -f *.o mytest

When I say make I get a bunch of errors.

Please help me in this regard

Upvotes: 1

Views: 1141

Answers (1)

pradeep
pradeep

Reputation: 31

I changed the my makefile as follows: after the changes it worked

all: mytest
export CPPUTEST_HOME=/usr/local
CPPFLAGS += -I$(CPPUTEST_HOME)/include 
LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt

mytest: test_main.o test.o
    g++ -g -o mytest test.o test_main.o $(LD_LIBRARIES)
test_main.o: test_main.cpp 
    g++ -g $(CPPFLAGS) -c test_main.cpp
test.o: test.cpp 
    g++ -g $(CPPFLAGS) -c test.cpp
clean:
    rm -f *.o mytest

Upvotes: 2

Related Questions