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.
$(CXX) $(FLAGS) client.o -o client
您只链接client.o
文件,而不是其他目标文件。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.