makefile - 为什么我的变量没有在我的 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 $@
^(命令前的空格是制表符)^
运行时,shell 输出
g++ -c -o SDLpp.o SDLpp.cpp
这表明其他变量没有在第一个模式规则中扩展。奇怪的是,只是CC
扩展为g++
. 为什么会这样?
解决方案
问题不是非扩展变量之一。相反,makefile 使用的是默认规则,而不是您提供的规则。
原因可能是您的规则使用IIRC *.c
,而您可能有文件。*.cpp
推荐阅读
- google-maps - 从 Waze Live 地图中提取交通数据的任何可能方法?
- ios - Ionic 4 iOS 应用程序使用 APNS 推送通知,无需第三方服务
- mysql - 如何优化多个连接
- go - 如何处理 Go 中包中支持文件的路径?
- regex - 如何获得正确的属性
- java - 即使使用 auto.offset.reset,我的 Java 消费者也无法从代理读取消息 - 最早
- lua - 尝试编辑包含特定键的数组
- apache-kafka - 如何编辑 JMX 配置文件以使 Kafka 公开主题?
- php - 使用 PHP Oauth 类创建 API 身份验证
- regex - 试图从 Postman 中的 post 调用中获取会话值:TypeError: postman.getResponseHeader is not a function