Linux基础PPT课件第七章多模块软件的编译和链接.ppt
《Linux基础PPT课件第七章多模块软件的编译和链接.ppt》由会员分享,可在线阅读,更多相关《Linux基础PPT课件第七章多模块软件的编译和链接.ppt(44页珍藏版)》请在三一办公上搜索。
1、多模块软件的编译和链接,第7章,预习检查,$make f 文件,是什么文件?遵循makefile语法的文件,也就是makefile文件目标列表:关联性列表,含义是什么?目标列表依赖于关联性列表简单变量的定义方式?变量名:=文本举一个make内置变量的例CFLAGS,$,$?等make clean,clean常见的含义是什么?clean是虚目标,删除make生成的文件,2,本章目标,了解Make实用程序的功能使用makefile管理多模块软件掌握makefile的规则,变量掌握makefile的虚目标规则了解autoconf的原理和用法,本章结构,简介,多模块软件的编译和链接,Makefile和
2、Make Rules,默认规则,虚目标,特殊目标,一般性语法错误及其纠正措施,autoconf,多模块软件、依赖树和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,管理多模块程
3、序的编译和连接读取一个说明文件-makefile描述系统中各模块的依赖关系Make使重编译的次数达到最小化Makefile描述的依赖关系各组件文件的时间戳Makefile 实质上是一种脚本语言,2-1Make,2-1make,2-1makefile,目标列表:关联性列表命令列表,目标列表:关联性列表;命令列表,也称为先决条件,2-1makefile,注释#连接符关联列表和命令列表中使用shell通配符?*,与shell脚本的相同,2-1makefile,实例,源码-power.c#include main()float x,y;printf(“the program take x and fr
4、om stdin and displays 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-1makefile,当目标文件比关联文件更新更新关联文件,对比,$makemake:poweris up to date,$touch powerC$makegcc power.c o powe
5、r lm,仅仅只更新文件的修改时间为当前时间,目标文件存在,且比关联文件更新,重新编译更新的关联文件,2-2依赖树,把power.c分成两个文件,#cat power.c#include double compute(double x,double y);main()float x,y;printf(”The program takes x from stdin and displays xy.n”);printf(”Enter number x:”);scanf(”f,&x);printf(”Enter number y:”);scanf(”f,&y);printf(”xy is:63fn”
6、,compute(x,y);,#cat compute.c#includedouble compute(double x,double y)return(pow(double)x,(double)y);,2-2依赖树,power.o,compute.o,power:gcc power.o compute.o-o power-lm,2-2依赖树,power.o,compute.o,power:gcc power.o compute.o-o power-lmpower.o:power.cgcc c power.ccompute.o:compute.cgcc c compute.c,power.c,
7、compute.c,$makegcc-c powercgcc-c computecgee powero computeo-o powerlm,树中节点的处理是自底向上的,由叶结点的符节点开始,2-2依赖树,进一步分成六个文件,建立依赖树,$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 val
8、ue of x:”const char*PROMPT2=”Enter the value of y:”,$cat inputC#include”inputh”double input(const char*s)floatx;printf(”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
9、);,2-2依赖树,$cat mainc#include#include”mainh”#include”computeh”#include”inputh”main()double x,y;printf(”The program takes X and Y from stdin and displays xy.n”);x=input(PROMPTl);y=input(PROMPT2);printf(”xy is:6.3fn”,compute(x,y);,2-2依赖树,$cat makefilepower:main.o input.o compute.o gcc main.o input.o co
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Linux 基础 PPT 课件 第七 模块 软件 编译 链接

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