1

我正在尝试学习 cpputest,所以去了 cpputest 手册并在我的 ubuntu 14.04lts 笔记本电脑中复制了以下代码,并尝试制作。我是新来的文件,我遇到了一堆错误 - 我该如何更正我的代码?

#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);
}

也就是说test.cpp,我的主要名称如下test_main.cpp

#include "CppUTest/CommandLineTestRunner.h"

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

制作文件是:

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

当我说 make 我得到一堆错误。

请在这方面帮助我

4

1 回答 1

2
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
于 2015-07-02T16:38:20.470 回答