第七章多模块软件的编译和链接.ppt
《第七章多模块软件的编译和链接.ppt》由会员分享,可在线阅读,更多相关《第七章多模块软件的编译和链接.ppt(37页珍藏版)》请在三一办公上搜索。
1、多模块软件的编译和链接,第7章,预习检查,$make f 文件,是什么文件?遵循makefile语法的文件,也就是makefile文件目标列表:关联性列表,含义是什么?目标列表依赖于关联性列表简单变量的定义方式?变量名:=文本举一个make内置变量的例CFLAGS,$,$?等make clean,clean常见的含义是什么?clean是虚目标,删除make生成的文件,2,本章目标,了解Make实用程序的功能使用makefile管理多模块软件掌握makefile的规则,变量掌握makefile的虚目标规则,本章结构,简介,多模块软件的编译和链接,Makefile和Make Rules,默认规则,
2、虚目标,特殊目标,一般性语法错误及其纠正措施,多模块软件、依赖树和make,Make实用程序,make实用程序对简单变量的支持,内建变量,命令行的使用和调试,1-1 多模块软件,实用的软件都是拥有多个源文件这些源文件称之为模块多模块软件多模块软件,2-1make,一个差强人意的办法使用shell脚本上述的缺点,导致了make的产生。,$cat build.scgcc c prog1.c prog2.c prog3.cgcc o prog prog1.o prog2.o prog3.o,2-1make,Make的产生,2-1make,管理多模块程序的编译和连接读取一个说明文件-Makefile描
3、述系统中各模块的依赖关系make使重编译的次数达到最小化Makefile描述的依赖关系各组件文件的时间戳Makefile 实质上是一种脚本语言,2-1Make,2-1make,2-1makefile,目标列表:关联性列表命令列表,目标列表:关联性列表;命令列表,也称为先决条件,2-1makefile,注释#连接符关联列表和命令列表中使用shell通配符?*,与shell脚本的相同,2-1makefile,实例,源码 power.c#include#include main()float x,y;printf(the program take x and from stdin and displ
4、ays xy.n);printf(enter number x:);scanf(%f,$cat MakefileSample makefile for the power programRemember:each command line starts with a TABpower:power.cgcc power.c-o power lm$,制表符,2-2依赖树,把power.c分成两个文件,#include double compute(double x,double y);main()float x,y;printf(the program take x and from stdin
5、and displays xy.n);printf(enter number x:);scanf(%f,#includedouble compute(double x,double y)return(pow(double)x,(double)y);,2-2依赖树,power.o,compute.o,power:power.o compute.ogcc power.o compute.o-o power-lm,2-2依赖树,power.o,compute.o,power:power.o compute.ogcc power.o compute.o-o power-lmpower.o:power.
6、cgcc c power.ccompute.o:compute.cgcc c compute.c,power.c,compute.c,$makegcc-c power.cgcc-c compute.cgcc power.o compute.o-o power lm,树中节点的处理是自底向上的,由叶结点的父节点开始,2-2makefile,当目标文件比关联文件更新更新关联文件,对比,$touch powerC$makegcc power.c o power lm,仅仅只更新文件的修改时间为当前时间,目标文件存在,且比关联文件更新,重新编译更新的关联文件,2-2依赖树,进一步分成六个文件,建立依赖
7、树,$cat computecincludeinclude”computeh”double compute(double x,double y)return(pow(double)x,(double)y);,$cat main.h/*Declaration of prompts to users*/const char*PROMPTl=”Enter the value of x:”;const char*PROMPT2=”Enter the value of y:”;,$cat inputC#include”inputh”double input(const char*s)floatx;pri
8、ntf(”s”,s);scanf(“f”,&x);return(x);,$cat input.h/*Declaration of the”input”function*/double input(char*);,cat computeh/*Declaration of the“compute”function*/double compute(double,double);,2-2依赖树,$cat mainc#include#include”mainh”#include”computeh”#include”inputh”main()double x,y;printf(”The program t
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 第七 模块 软件 编译 链接

链接地址:https://www.31ppt.com/p-5147802.html