某大佬曾说过:

不会makefile,不要说你会linux,因为makefile是合格程序员的必经之路

首先你要有个vi或者emacs 之类的编辑器

编写几个程序

test1.c

 #include<stdio.h>
#include "test2.h" int main()
{
printf("This is test1!\n");
PrintTest2();
return ;
}

test2.c

 #include<stdio.h>
#include "test2.h" int main()
{
printf("This is test1!\n");
PrintTest2();
return ;
}

test2.h:

  #ifndef TEST2_H_
#define TEST2_H_ void PrintTest2(); #endif

然后你的makefile

需要建立一个文件叫makefile(可以是MAKEFILE)-------但是只能是这两个名字

接下来就是makefile中的内容

 test: test1.o test2.o //这是主要的文件,后面两个是形成的执行文件
gcc -Wall test1.o test2.o -o test test1.o: test1.c test2.h//底下这些就是每一个执行文件所包含的.c .h文件
gcc -c -Wall test1.c -o test1.o//编译 test2.o: test2.c test2.h//执行文件所包含的.c .h文件
gcc -c -Wall test2.c -o test2.o clean: //删除
rm -rf *.o test

运行的时候是

./test

可以用"代号":使用变量

前几行是声明

varname = xxx

底下写的时候就直接用就行

使用的时候要$(varname)

 OBJS = test1.o test2.o
G = gcc
CFLAGS = -Wall -O -g test:$(OBJS)
$(G) $(OBJS) -o test test1.o:test1.c test2.h
$(G) $(CFLAGS) -c test1.c
test2.o:test2.c test2.h
$(G) $(CFLAGS) -c test2.c clean:
rm -rf *.o test

makefile加油呀!

最新文章

  1. 关于SilverLight
  2. angularjs 自带的过滤器
  3. http://www.cnblogs.com/younggun/archive/2013/07/16/3193800.html
  4. Effective C++ 沉思录
  5. HTTP基本协议(查看网页代码)
  6. (Python3) 连加 连乘 代码
  7. vue-lazyload懒加载插件的使用
  8. CSS中清除浮动的作用以及如何清除浮动
  9. TCP/UDP 协议
  10. SAP 从数据库中查询数据,带有where 条件。
  11. springMVC学习 七 视图解析器
  12. HDU 2066 一个人的旅行 最短路问题
  13. R语言 如何用IF语句判断 一个数字的奇偶
  14. ZOJ 3946.Highway Project(The 13th Zhejiang Provincial Collegiate Programming Contest.K) SPFA
  15. apicloud管理
  16. jdbc批处理
  17. (转) bicabo Visual Studio 2012自动添加注释(如版权信息等)
  18. IEnumerable&lt;T&gt; 接口和GetEnumerator 详解
  19. 浅谈iOS学习之路(转)
  20. SSH笔记一

热门文章

  1. mysql根据一张表更新另一张表数据
  2. 查看笔记本SN序列号
  3. Data types &#39;int&#39; and &#39;float&#39;
  4. 进阿里真的这么难?P8大佬告诉你,你和阿里之间缺的只是这份笔记
  5. Rust String(官方文档翻译)
  6. EntityFrameworkCore 开发实践问题及规范
  7. Dynamics CRM Data Encrytion error
  8. Python之协程、异步IO、redis缓存、rabbitMQ队列
  9. 关于springboot中过滤器和拦截器
  10. easyui datagrid 中添加combobox