当前位置:网站首页>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 基本语法
待定
边栏推荐
猜你喜欢

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

方法递归(斐波那契数列,青蛙跳台阶,汉诺塔问题)

Principes fondamentaux de la théorie musicale (brève introduction)

双向链表的实现(双向链表与单向链表的简单区别联系和实现)

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

Intelligent manufacturing solutions digital twin smart factory

Sqlyog remote connection to MySQL database under centos7 system

Array and string processing, common status codes, differences between PHP and JS (JS)

顺序表基本功能函数的实现

Use of OpenCV 6.4 median filter
随机推荐
Dynamic extensible representation for category incremental learning -- der
Summary of one question per day: stack and queue (continuously updated)
Intelligent manufacturing solutions digital twin smart factory
STM32疑难杂症之ST-LINK Connection error INVALID ROM TABLE
STM32-新建工程(参考正点原子)
Longest isometric subsequence
Carla-ue4editor import Roadrunner map file (nanny level tutorial)
Library function of C language
Static library and dynamic library
Use the kaggle training model and download your own training model
How to apply for a secondary domain name?
SQL操作数据库语法
我的vim配置文件
Global and Chinese market of snow sweepers 2022-2028: Research Report on technology, participants, trends, market size and share
Development of digital collection trading website development of metauniverse digital collection
使用wireshark抓取Tcp三次握手
双向链表的实现(双向链表与单向链表的简单区别联系和实现)
稀疏矩阵存储
OpenCV3 6.2 低通滤波器的使用
Causes of laptop jam