我写了这个问候世界hello.c:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
exit( 0 );
}
Run Code Online (Sandbox Code Playgroud)
我Makefile是:
%: %.c
Run Code Online (Sandbox Code Playgroud)
当我运行时,make我会收到此错误:make: *** No targets. Stop.
你的makefile提供了一个规则, %: %.c规定它是你感兴趣的无扩展可执行文件和.c文件(事实上,只是内置规则那么做),但没有提示有一个命名的源文件hello.c或一个名为的目标hello.
当你自己键入时make,make会将makefile中列出的第一个目标作为目标,但你的makefile不包含任何目标,因此没有目标.停止.简而言之,make不知道附近有什么名字像hello*.
使用你的makefile,键入make hello将做你想要的,因为它告诉你想要构建什么.
如果你告诉make hello,你也可以输入make你想做的事情:
hello: hello.c
%: %.c
Run Code Online (Sandbox Code Playgroud)
或更具惯用性和灵活性,您将列出目标中的所有"顶级" all目标:
all: hello
%: %.c
.PHONY: all
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
198 次 |
| 最近记录: |