我的makefile出了什么问题?找不到实施

时间:2014-06-22 01:31:06

标签: c++ makefile

这是我的Makefile:

CC = g++
CFLAGS = -std=c++11 

default: main

main: core.o
    $(CC) $(CFLAGS) main.cpp core.o -o run.exe

core.o: core.h core.cpp display.h eventhandler.h
    $(CC) $(CFLAGS) -c core.cpp

eventhandler.o: eventhandler.h eventhandler.cpp
    $(CC) $(CFLAGS) -c eventhandler.cpp

clean:
    $(RM) run.exe *.o *~

但是当我尝试编译它时,我得到一个错误,说它无法找到eventhandler.cpp中定义的函数的实现,但我确信它就在那里。我做错了什么?

1 个答案:

答案 0 :(得分:2)

main: core.o
    $(CC) $(CFLAGS) main.cpp core.o -o run.exe

应该是

main: core.o eventhandler.o
    $(CC) $(CFLAGS) main.cpp core.o eventhandler.o -o run.exe