makefile 的使用

来源:互联网 发布:windows 预览体验服务 编辑:程序博客网 时间:2024/05/02 20:44

查看makefile的版本  make -v

安装  sudo apt-get install apt-get install make

大型项目 都是使用makefile来管理编译的


文件名 必须命名为Makefile

内容如下(ps:必须要制表符tab键来)

demo2.out:max.o min.o demo2.c
gcc max.o min.o demo2.c -o demo2.out
max.o:max.c
gcc -c max.c -o max.o
min.o:min.c
gcc -c min.c -o min.o

demo2.c的源文件如下

#include <stdio.h>

#include "max.h"
#include "min.h"
int main()
{
int a=13;
int b=14;
int c=max(a,b);
        int d=min(a,b);
        printf("the max number is %d\n the min number is %d",c,d);
return 0;


}

执行make 则开始编译,生成了min.o max.o 和demo2.out

执行 ./demo2.out 就可以看到运行结果了。






0 0
原创粉丝点击