当前位置:网站首页>Makefile基本原理
Makefile基本原理
2022-07-02 06:28:00 【藤原千花的败北】
什么是Makefile
GNU make (and other variants of make) do precisely this. make defines a language for describing the relationships between source code, intermediate files, and executables. It also provides features to manage alternate configurations, implement reusable libraries of specifications, and parameterize processes with user-defined macros.
In short, make can be considered the center of the development process by providing a roadmap of an application’s components and how they fit together.
GNU make(以及make的其他变体)正是这样做的。make定义了一种用于描述源代码、中间文件和可执行文件之间的关系的语言。它还提供了管理可选配置、实现可复用规范库和使用用户定义的宏对进程进行参数化的特性。
简而言之,make可以被视为开发过程的中心(通过提供应用程序的组件及其如何组合的路线图)。
编程的机制通常遵循一个相当简单的流程,编辑程序源文件,将源文件编译成可执行形式,并调试结果。下面是一个C源文件转换为可执行文件的过程:
- 预处理器:将.c 文件转化成 .i 文件,使用的 gcc 命令是:gcc –E,对应于预处理命令 cpp;
- 编译器:将.c/.h 文件转换成.s 文件,使用的 gcc 命令是:gcc –S,对应于编译命令 cc –S;
- 汇编器:将.s 文件转化成 .o 文件,使用的 gcc 命令是:gcc –c,对应于汇编命令是 as;
- 链接器:将.o 文件转化成可执行程序,使用的 gcc 命令是: gcc,对应于链接命令是 ld;
- 加载器:将可执行程序加载到内存并进行执行,loader 和 ld-linux.so。
make是一个构建工具,通过解析makefile里面的描述,对整个工程项目进行编译构建。
提示:以下是本篇文章正文内容,下面案例可供参考
一、为什么要用Makefile
make主要解决两个问题:
- 大量代码的关系维护
大项目中源代码比较多,手工维护、编译时间长而且编译命令复杂,难以记忆及维护
把代码维护命令及编译命令写在makefile文件中,然后再用make工具解析此文件自动执行相应命令,可实现代码的合理编译
- 减少重复编译时间
n 在改动其中一个文件的时候,能判断哪些文件被修改过,可以只对该文件进行重新编译,然后重新链接所有的目标文件,节省编译时间
二、Makefile 基本语法
待定
边栏推荐
- 【无标题】
- A brief analysis of graph pooling
- 業務架構圖
- Constant pointer and pointer constant
- Brief introduction of prompt paradigm
- Using transformer for object detection and semantic segmentation
- Introduction to anti interception technology of wechat domain name
- MySQL优化
- Carsim-实时仿真的动画同步问题
- Global and Chinese markets for conventional rubber track 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Chinese garbled code under vscade
Use C language to receive JSON strings
Dynamic extensible representation for category incremental learning -- der
2022 Heilongjiang latest food safety administrator simulation exam questions and answers
Principes fondamentaux de la théorie musicale (brève introduction)
Matlab mathematical modeling tool
How to wrap qstring strings
OpenCV3 6.3 用滤波器进行缩减像素采样
VS Code配置问题
2022 Heilongjiang latest construction eight members (materialman) simulated examination questions and answers
随机推荐
Multi site high availability deployment
Carsim-路面3D形状文件参数介绍
Wang extracurricular words
静态库和动态库
力扣每日一题刷题总结:字符串篇(持续更新)
Carsim 学习心得-粗略翻译1
Introduction to anti interception technology of wechat domain name
Animation synchronization of CarSim real-time simulation
【无标题】
实现双向链表(带傀儡节点)
On the back door of deep learning model
力扣方法总结:滑动窗口
用C# 语言实现MYSQL 真分页
程序猿学英语-Learning C
2022 Heilongjiang's latest eight member (Safety Officer) simulated test question bank and answers
OpenCV 6.4 中值滤波器的使用
学习写文章格式
Jupyter Notebook常用快捷键(在命令模式中按H也可查看)
Force buckle method summary: sliding window
On the confrontation samples and their generation methods in deep learning