在
制作
编译和运行目标都被重建,即使文件 One.c 没有做任何更改
all: compile run
compile: One.c
gcc One.c -o One
run: One
./One
.PHONY: run
我使用 Ubuntu-15.04 作为操作系统,使用 Geany 作为编辑器。
One.c 只包含一个打印语句“hello world”。
在
制作
编译和运行目标都被重建,即使文件 One.c 没有做任何更改
all: compile run
compile: One.c
gcc One.c -o One
run: One
./One
.PHONY: run
我使用 Ubuntu-15.04 作为操作系统,使用 Geany 作为编辑器。
One.c 只包含一个打印语句“hello world”。
当您运行make
时,它将尝试在 makefile ( all
) 中构建第一条规则,该规则取决于目标compile
和run
.
run
是假的,无论如何都会运行。compile
是非假的,但没有名为 的文件compile
,所以 make 将尝试构建这个目标(期望它产生compile
文件,但它不会)。
您需要在One
此处添加非假目标并构建您的二进制文件,例如:
all: compile run
compile: One
One: One.c
gcc One.c -o One
run: One
./One
.PHONY: run compile