这是我的生成文件:
#Makefile
CC=g++
CFLAGS=-lcppunit
OBJS=Money.o MoneyTest.o
all : $(OBJS)
$(CC) $(OBJS) -o TestUnitaire
#création des objets
Money.o: Money.cpp Money.hpp
$(CC) -c Money.cpp $(CFLAGS)
MoneyTest.o: MoneyTest.cpp Money.hpp MoneyTest.hpp
$(CC) -c MoneyTest.cpp $(CFLAGS)
clean:
rm *.o $(EXEC)
当我运行这个makefile时,我得到了这样的错误:
g++ Money.o MoneyTest.o -o TestUnitaire Money.o: 在函数
main': Money.cpp:(.text+0x3c): undefined reference to
CppUnit::TestFactoryRegistry::getRegistry(std::basic_string, std::allocator > const&)' Money.cpp:(.text+0x78): 未定义引用到CppUnit::TextTestRunner::TextTestRunner(CppUnit::Outputter*)' Money.cpp:(.text+0x8c): undefined reference to
CppUnit::TestRunner::addTest(CppUnit::Test*)' Money.cpp:(.text+0x98): 未定义对CppUnit::TextTestRunner::result() const' Money.cpp:(.text+0xec): undefined reference to
CppUnit::CompilerOutputter::CompilerOutputter(CppUnit::TestResultCollector*, std::basic_ostream >&的引用, std::basic_string, std::allocator > const&)' Money.cpp:(.text+0xfc): 未定义引用CppUnit::TextTestRunner::setOutputter(CppUnit::Outputter*)' Money.cpp:(.text+0x168): undefined reference to
CppUnit::TextTestRunner::run(std::basic_string, std::allocator >, bool, bool , bool)' Money.cpp:(.text+0x1a5): 未定义对CppUnit::TextTestRunner::~TextTestRunner()' Money.cpp:(.text+0x233): undefined reference to
CppUnit::TextTestRunner::~TextTestRunner() 的引用
我的班级之间似乎没有联系。有什么问题?