【发布时间】:2020-04-03 20:25:40
【问题描述】:
我有 3 个文件: Source.cpp 2ndfile.cpp 2ndfile.hpp 我正在尝试用 mingw32-make 编译它们
makefile 不起作用:
all: launch.exe
launch.exe: %.o
g++ -o $@ $^
%.o: %.cpp
g++ -c $< -std=gnu++11
有效的生成文件:
all: launch.exe
launch.exe: source.o 2ndfile.o
g++ -o $@ $^
source.o: source.cpp
g++ -c source.cpp -std=gnu++11
2ndfile.o: 2ndfile.cpp
g++ -c 2ndfile.cpp -std=gnu++11
我的问题是:为什么第一个不起作用? '%' 模式有什么问题?
我得到的错误:mingw32-make: *** No rule to make target '%.o', needed by 'launch.exe'. Stop.
【问题讨论】: