当前位置:网站首页>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 基本语法
待定
边栏推荐
- Opencv common method source link (continuous update)
- What are the platforms for selling green label domain names? What is the green label domain name like?
- SQL操作数据库语法
- Use Matplotlib to draw a preliminary chart
- My VIM profile
- On November 24, we celebrate the "full moon"
- Learn to write article format
- Organigramme des activités
- Sparse matrix storage
- 乐理基础(简述)
猜你喜欢

Specification for package drawing

Simple implementation scheme of transcoding and streaming (I)

Use of OpenCV 6.4 median filter

OpenCV3 6.2 低通滤波器的使用

MySQL优化

C语言实现XML生成解析库(XML扩展)

Data reverse attack under federated learning -- gradinversion

旋转链表(图解说明)

Matlab mathematical modeling tool

Simply test the two different data transmission methods of content length and chunked
随机推荐
On the back door of deep learning model
Opencv common method source link (continuous update)
2022 Heilongjiang latest construction eight members (materialman) simulated examination questions and answers
The best blog to explain the basics of compilation (share)
Real world anti sample attack against semantic segmentation
Opencv3 6.3 reduced pixel sampling with filters
C语言的库函数
DWORD ptr[]
STL quick reference manual
E-R draw clear content
Animation synchronization of CarSim real-time simulation
Simply test the two different data transmission methods of content length and chunked
Global and Chinese market of electric cheese grinder 2022-2028: Research Report on technology, participants, trends, market size and share
Principes fondamentaux de la théorie musicale (brève introduction)
Rhel7 operation level introduction and switching operation
乐理基础(简述)
STM32-新建工程(参考正点原子)
Sqlyog remote connection to MySQL database under centos7 system
Sparse matrix storage
Target detection for long tail distribution -- balanced group softmax