在过去的半小时里,我尝试寻找有类似问题的人,但是我找不到任何关于为什么这表明该文件是最新的,而它根本不存在。
这是现在的makefile:
SOURCES = \
Core\SnowApp.cpp \
Core\SnowApp_Render.cpp \
Core\SnowApp_Tick.cpp \
Core\InputState.cpp \
Graphics\RenderingScreen.cpp \
Graphics\SpriteSheet.cpp \
Maps\Map.cpp \
Entities\Entity.cpp \
Entities\MovingEntity.cpp \
Entities\Player.cpp \
_SOURCES = $(SOURCES:.cpp=.o)
OBJECTS = $(subst \,_,$(_SOURCES))
SRCDIR=src
OBJDIR=obj
BINDIR=bin
EXECUTABLE=snow.exe
CFLAGS= -c -Wall
LFLAGS= -o
LLIBS= -lmingw32 -lSDLmain -lSDL
CC=g++
COMPILE=$(CC) $(CFLAGS) $(LFLAGS) $@ $<
LINK=$(CC) $(LFLAGS) $@ $^ $(LLIBS)
$(BINDIR)\$(EXECUTABLE): $(addprefix $(OBJDIR)\,$(OBJECTS))
$(LINK)
$(OBJDIR)\Core_SnowApp.o: \
$(SRCDIR)\Core\SnowApp.cpp $(SRCDIR)\Core\SnowApp.h \
$(SRCDIR)\Graphics\RenderingScreen.h $(SRCDIR)\Maps\Map.h \
$(SRCDIR)\Core\InputState.h
$(COMPILE)
$(OBJDIR)\Core_SnowApp_Render.o: \
$(SRCDIR)\Core\SnowApp_Render.cpp $(SRCDIR)\Core\SnowApp.h \
$(SRCDIR)\Graphics\RenderingScreen.h
$(COMPILE)
$(OBJDIR)\Core_SnowApp_Tick.o: \
$(SRCDIR)\Core\SnowApp_Tick.cpp $(SRCDIR)\Core\SnowApp.h
$(COMPILE)
$(OBJDIR)\Core_InputState.o: \
$(SRCDIR)\Core\InputState.cpp $(SRCDIR)\Core\InputState.h
$(COMPILE)
$(OBJDIR)\Graphics_SpriteSheet.o: \
$(SRCDIR)\Graphics\SpriteSheet.cpp $(SRCDIR)\Graphics\SpriteSheet.h
$(COMPILE)
$(OBJDIR)\Graphics_RenderingScreen.o: \
$(SRCDIR)\Graphics\RenderingScreen.cpp $(SRCDIR)\Graphics\RenderingScreen.h \
$(SRCDIR)\Graphics\SpriteSheet.h
$(COMPILE)
$(OBJDIR)\Maps_Map.o: \
$(SRCDIR)\Maps\Map.cpp $(SRCDIR)\Maps\Map.h \
$(SRCDIR)\Graphics\RenderingScreen.h $(SRCDIR)\Core\InputState.h
$(COMPILE)
$(OBJDIR)\Entities_Entity.o: \
$(SRCDIR)\Entities\Entity.cpp $(SRCDIR)\Entities\Entity.h \
$(SRCDIR)\Graphics\RenderingScreen.h $(SRCDIR)\Core\InputState.h \
$(SRCDIR)\Maps\Map.h
$(COMPILE)
$(OBJDIR)\Entities_Player.o: \
$(SRCDIR)\Entities\Player.cpp $(SRCDIR)\Entities\Player.h \
$(SRCDIR)\Maps\Map.h $(SRCDIR)\Graphics\RenderingScreen.h \
$(SRCDIR)\Core\InputState.h
$(COMIPLE)
$(OBJDIR)\Entities_MovingEntity.o: \
$(SRCDIR)\Entities\MovingEntity.cpp $(SRCDIR)\Entities\MovingEntity.h \
$(SRCDIR)\Graphics\RenderingScreen.h $(SRCDIR)\Core\InputState.h \
$(SRCDIR)\Entities\Entity.h $(SRCDIR)\Maps\Map.h
$(COMPILE)
clear:
del /Q $(OBJDIR)\* $(BINDIR)\*
variables:
echo $(SOURCES)
echo $(OBJECTS)
echo $(SRCDIR)
echo $(OBJDIR)
echo $(BINDIR)
echo $(EXECUTABLE)
echo $(COMPILE)
echo $(LINK)
makefolders:
if not exist $(SRCDIR) mkdir $(SRCDIR)
if not exist $(OBJDIR) mkdir $(OBJDIR)
if not exist $(BINDIR) mkdir $(BINDIR)
我的问题是,当使用 mingw32-make 时,它将创建除 obj\Entities_Player.o 之外的所有文件,它说它始终是最新的。下面是一些命令行输出(为了便于使用,我重命名了 mingw32-make):
C:\Users\Mike\Documents\CodeProjects\Snow\trunk>make clear
del /Q obj\* bin\*
C:\Users\Mike\Documents\CodeProjects\Snow\trunk>dir obj
Volume in drive C has no label.
Volume Serial Number is D29B-6E0B
Directory of C:\Users\Mike\Documents\CodeProjects\Snow\trunk\obj
03/13/2013 11:33 AM <DIR> .
03/13/2013 11:33 AM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 80,363,814,912 bytes free
C:\Users\Mike\Documents\CodeProjects\Snow\trunk>make
g++ -c -Wall -o obj\Core_SnowApp.o src\Core\SnowApp.cpp
g++ -c -Wall -o obj\Core_SnowApp_Render.o src\Core\SnowApp_Render.cpp
g++ -c -Wall -o obj\Core_SnowApp_Tick.o src\Core\SnowApp_Tick.cpp
g++ -c -Wall -o obj\Core_InputState.o src\Core\InputState.cpp
g++ -c -Wall -o obj\Graphics_RenderingScreen.o src\Graphics\RenderingScreen.cpp
g++ -c -Wall -o obj\Graphics_SpriteSheet.o src\Graphics\SpriteSheet.cpp
g++ -c -Wall -o obj\Maps_Map.o src\Maps\Map.cpp
g++ -c -Wall -o obj\Entities_Entity.o src\Entities\Entity.cpp
g++ -c -Wall -o obj\Entities_MovingEntity.o src\Entities\MovingEntity.cpp
g++ -o bin\snow.exe obj\Core_SnowApp.o obj\Core_SnowApp_Render.o obj\Core_SnowAp
p_Tick.o obj\Core_InputState.o obj\Graphics_RenderingScreen.o obj\Graphics_Sprit
eSheet.o obj\Maps_Map.o obj\Entities_Entity.o obj\Entities_MovingEntity.o obj\En
tities_Player.o -lmingw32 -lSDLmain -lSDL
g++: error: obj\Entities_Player.o: No such file or directory
make: *** [bin\snow.exe] Error 1
C:\Users\Mike\Documents\CodeProjects\Snow\trunk>make obj\Entities_Player.o
make: `obj\Entities_Player.o' is up to date.
C:\Users\Mike\Documents\CodeProjects\Snow\trunk>dir obj\Entities_Player.o
Volume in drive C has no label.
Volume Serial Number is D29B-6E0B
Directory of C:\Users\Mike\Documents\CodeProjects\Snow\trunk\obj
File Not Found
C:\Users\Mike\Documents\CodeProjects\Snow\trunk>
首先,我清空我的 obj 目录并显示它是空的。然后我调用 make ,对于我过去在 SOURCES 变量中的文件,将所有 .cpp 文件构建为驻留在 obj 中的 .o 文件。这一步跳过了 obj\Entities_Player.o 所以,我们自己检查它,看看它是最新的,但是没有找到。我们再次检查 .o 文件是否在目录中,而实际上不在。对于它的价值,如果我使用 g++ 手动编译它并手动通过 $(COMPILE) 行,我最终能够编译文件,然后制作项目:
C:\Users\Mike\Documents\CodeProjects\Snow\trunk>g++ -c -Wall -o obj\Entities_Pla
yer.o src\Entities\Player.cpp
C:\Users\Mike\Documents\CodeProjects\Snow\trunk>make
g++ -o bin\snow.exe obj\Core_SnowApp.o obj\Core_SnowApp_Render.o obj\Core_SnowAp
p_Tick.o obj\Core_InputState.o obj\Graphics_RenderingScreen.o obj\Graphics_Sprit
eSheet.o obj\Maps_Map.o obj\Entities_Entity.o obj\Entities_MovingEntity.o obj\En
tities_Player.o -lmingw32 -lSDLmain -lSDL
C:\Users\Mike\Documents\CodeProjects\Snow\trunk>
也许我只是需要用新的眼光看待它,也许还有一些我不知道的关于 make 的事情。如果您能想到任何事情,我将非常感谢您的帮助。