Reputation: 2396
When trying to compile a project I have made I am getting a
undefined reference to `Timers::NextTimerTime(timeval*)'
which is a method I have defined in timers.cc, but am using in client.cpp. I have included the correct header file, but it can not find the definition in the timers.cc file.
CXX = g++
CPPFLAGS = -I. -g -Wall -fno-inline
FLAGS = ${CPPFLAGS} ${AC_DEFS}
all: client
default:
all
tools.o: tools.cc tools.hh
$(CXX) $(FLAGS) -c tools.cc
timers.o: timers.cc timers.hh
$(CXX) $(FLAGS) -c timers.cc
client.o: client.cpp client.h
$(CXX) $(FLAGS) -c client.cpp
client: client.o timers.o tools.o
$(CXX) $(FLAGS) client.o -o client
clean:
rm -f client *.o
This code compiles in eclipse, but I can not generate a make file for it.
Upvotes: 0
Views: 80
Reputation: 409442
$(CXX) $(FLAGS) client.o -o client
You're only linking with the client.o
file, not the other object files.
Upvotes: 2