您的位置:首页 > 其它

makefile 的使用

2015-12-14 23:00 204 查看
查看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 就可以看到运行结果了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: