我正在学习 Zed Shaw 的 Learn C The Hard Way 类(class),在第 2 课中,我发现在视频和书中,作者只使用 make ex1
来编译他的 C,而我需要运行 gcc -Wall -g ex1.c -o ex1
。这是我的 Makefile,看起来第一部分应该是让 make 命令可以编译的,但是“make”命令没有编译它。
CFLAGs=-Wall -g
clean:
rm -f ex1.exe
all:
gcc -Wall -g ex1.c -o ex1.exe
最佳答案
默认目标是第一个目标,因此请切换这些目标的顺序,使 all
成为默认目标。
the documentation on goals 中有更多详细信息:
By default, the goal is the first target in the makefile (not counting targets that start with a period). Therefore, makefiles are usually written so that the first target is for compiling the entire program or programs they describe. If the first rule in the makefile has several targets, only the first target in the rule becomes the default goal, not the whole list. You can manage the selection of the default goal from within your makefile using the .DEFAULT_GOAL
variable
关于c - 设置我的 makefile 以仅使用 "make"编译 C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54119488/