hello.c的内容如下:
#include <stdio.h>
int main()
{
    printf("Hello World!\n");
    return 0;
}
makefile 的内容如下:
hello.exe : hello.o
    gcc -o hello.exe hello.o
hello.o : hello.c   
    gcc -c hello.c
clean :  
    rm hello.o hello.exe
Windows命令行(cmd.exe)下,先进入makefile 所在目录,执行 make 命令。

就会生成hello.exe了。

注意:
1, makefile 文件没有扩展名。
2, 第二、第四行、第六行前必须有一个tab
posted on 2022-07-29 11:21  闻缺陷则喜何志丹  阅读(4)  评论(0编辑  收藏  举报  来源