为什么我的变量没有在我的 makefile 中扩展?

Why aren't my variables expanding in my makefile?

我正在使用 mingw32-make 到 运行 我的 makefile。 Makefile的内容如下:

#OBJS specifies which files to compile as part of the project 
OBJS = SDLpp.o SDLpp_exception.o SDLpp_window.o

#CC specifies which compiler we're using 
CC = g++ 

#INCLUDE_PATHS specifies the additional include paths we'll need 
INCLUDE_PATHS = -IC:\mingw_dev_lib\include\SDL2 \
                -IC:\mingw_dev_lib\include\SDL_image \
                -IC:\mingw_dev_lib\include\SDLpp

#LIBRARY_PATHS specifies the additional library paths we'll need 
LIBRARY_PATHS = -LC:\mingw_dev_lib\lib

#COMPILER_FLAGS specifies the additional compilation options we're using 
# -w suppresses all warnings 
# -Wall includes all warnings
# -Wl,-subsystem,windows gets rid of the console window 
COMPILER_FLAGS = -Wall

#LINKER_FLAGS specifies the libraries we're linking against 
LINKER_FLAGS = -lmingw32 -lSDL2main -lSDL2 -lSDL2_image

#LIB_NAME specifies the name of our library 
LIB_NAME = libSDLcpp.a

#This is the target that compiles our executable 

all : $(OBJS)
    ar rvs $(LIB_NAME) $(OBJS)

%.o : %.c
    $(CC) $< $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) -c $(LINKER_FLAGS) -o $@ 

^(命令前的白色-space是制表符)^

当运行时,shell输出

g++ -c -o SDLpp.o SDLpp.cpp

这表明其他变量没有在第一个模式规则中展开。奇怪的是,只有 CC 扩展到 g++。为什么会这样?

问题不是非扩展变量之一。相反,makefile 使用默认规则而不是您提供的规则。

原因可能是您的规则使用 *.c,而您可能有 *.cpp 个文件,IIRC。