The -lcppunit
flag is not correct in CFLAGS
, which is where you put C compiler flags. You are (a) compiling C++ programs, not C programs, and (b) the -l
flag is a linker flag, not a compiler flag. Also, the CC
variable holds the C compiler. You should use the CXX
variable for the C++ compiler. Your makefile should look something like:
#Makefile
CXX = g++
LDLIBS = -lcppunit
OBJS = Money.o MoneyTest.o
all : TestUnitaire
TestUnitaire: $(OBJS)
$(CXX) $^ -o $@ $(LDFLAGS) $(LDLIBS)
#création des objets
%.o : %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
Money.o: Money.hpp
MoneyTest.o: Money.hpp MoneyTest.hpp
clean:
rm *.o $(EXEC)