当前位置:网站首页>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 基本语法
待定
边栏推荐
- Carla-ue4editor import Roadrunner map file (nanny level tutorial)
- Principes fondamentaux de la théorie musicale (brève introduction)
- Learn to write article format
- Cvpr19 deep stacked hierarchical multi patch network for image deblurring paper reproduction
- Sequence problem for tqdm and print
- C language implements XML generation and parsing library (XML extension)
- Opencv3 6.3 reduced pixel sampling with filters
- Carsim-问题Failed to start Solver: PATH_ID_OBJ(X) was set to Y; no corresponding value of XXXXX?
- St-link connection error invalid ROM table of STM32 difficult and miscellaneous diseases
- Opencv's experience of confusing X and Y coordinates
猜你喜欢

Smart agriculture solutions smart agriculture system development

Use Matplotlib to draw a preliminary chart

2022 Heilongjiang latest food safety administrator simulation exam questions and answers

Carsim problem failed to start Solver: Path Id Obj (X) was set to y; Aucune valeur de correction de xxxxx?

Cvpr19 deep stacked hierarchical multi patch network for image deblurring paper reproduction

Generate database documents with one click, which can be called swagger in the database industry

How to back up the configuration before the idea when reinstalling the idea

Data reverse attack under federated learning -- gradinversion

Opencv3 6.3 reduced pixel sampling with filters

Carsim-路面3D形状文件参数介绍
随机推荐
Use C language to receive JSON strings
Global and Chinese markets for magnetic resonance imaging (MRI) transmission 2022-2028: Research Report on technology, participants, trends, market size and share
Wang extracurricular words
Smart agriculture solutions smart agriculture system development
STL quick reference manual
Erase method in string
Multi site high availability deployment
Causes of laptop jam
Use Matplotlib to draw a preliminary chart
Summary of one question per day: String article (continuously updated)
Development of digital collection trading website development of metauniverse digital collection
Dynamic extensible representation for category incremental learning -- der
简易打包工具的安装与使用
Target detection for long tail distribution -- balanced group softmax
Find and rfind methods in string
Rhel7 operation level introduction and switching operation
乐理基础(简述)
Global and Chinese market of tillage finishing machines 2022-2028: Research Report on technology, participants, trends, market size and share
链表经典面试题(反转链表,中间节点,倒数第k个节点,合并分割链表,删除重复节点)
The internal network of the server can be accessed, but the external network cannot be accessed