我正在开发一个 SDL 项目,我使用 makefile 来构建它。我正在使用 MinGW w64 编译器和 make 在 Windows 上执行此操作。
我的项目结构看起来像这样
proj
------>bin #stores the executable
------>include #stroes the external library include files
------>lib #stores the lib files of the libraries
------>obj #stores the .o files
------>src #source files
makefile
Run Code Online (Sandbox Code Playgroud)
我的 makefile 看起来像这样
CC = g++
OUT = main
ODIR = ./obj
SDIR = ./src
OUTDIR = ./bin
IDIR = ./include
LDIR = ./lib
libs = -lmingw32 -lSDL2main -lSDL2
OBJS = $(patsubst $(SDIR)/%.cpp,$(ODIR)/%.o,$(wildcard $(SDIR)/*.cpp))
$(ODIR)/%.o : $(SDIR)/%.cpp
$(CC) …Run Code Online (Sandbox Code Playgroud)