当前位置:网站首页>黑猫带你学Makefile第2篇:程序编译的过程
黑猫带你学Makefile第2篇:程序编译的过程
2022-08-08 19:06:00 【黑猫学长呀】
本文结合个人工作/学习经验、网络资料辛苦整理/撰写而成,付费内容,禁止转载。
本文所在专栏《黑猫带你学Makefile》
1 程序如何编译、链接
想要学习makefile,就得了解代码编译链接的过程。
一般来说,无论是C、C++、还是lua,首先要把源文件编译成中间代码文件,在Windows下也就是 .obj 文件,UNIX下是 .o 文件,即 Object File,这个动作叫做编译(compile)。然后再把大量的Object File合成执行文件,这个动作叫作链接(link)。
编译时,编译器需要的是语法的正确,函数与变量的声明的正确。对于后者,通常是你需要告诉编译器头文件的所在位置(头文件中应该只是声明,而定义应该放在C/C++文件中),只要所有的语法正确,编译器就可以编译出中间目标文件。一般来说,每个源文件都应该对应于一个中间目标文件(O文件或是OBJ文件)。
链接时,主要是链接函数和全局变量,所以,我们可以使用这些中间目标文件(O文件或是OBJ文件)来链接我们的应用程序。链接器并不管函数所在的源文件,只管函数的中间目标文件(Object File),在大多数时候,由于源文件太多,编译生成的中间目标文件太多,而在链接时需要明显地指出中间目标
边栏推荐
- Goose Factory Robot Dog Fancy Crossing 10m Plum Blossom Pile: Front Flip, Single Pile Jump, Get Up and Bow... No stumble in the whole process
- Codeforces Round #721 (Div. 2)
- 使用 lua 运行 fscript
- 无标题文章
- C language elementary - structure
- hdu2647 N!Again
- 达梦数据库 DmAPservice服务,启停影响 DMSERVER库服务吗?
- 数字化工厂建设的内容主要有哪三个方面
- uniapp parent component uses prop to pass asynchronous data to child components
- What are the three main aspects of digital factory construction?
猜你喜欢
Advanced CAD practice (2)
Geometric g6 will carry harmonyos system, a comprehensive upgrade competitiveness of products
Goose Factory Robot Dog Fancy Crossing 10m Plum Blossom Pile: Front Flip, Single Pile Jump, Get Up and Bow... No stumble in the whole process
Why Manufacturing Companies Should Deploy Digital Factory Systems
Generate captchas tools
What are the three main aspects of digital factory construction?
软件测试主要是做什么的?
Dandelion R300A 4G router, remote monitoring PLC tutorial
架构设计基本原则
MogDB study notes - starting from 0
随机推荐
hdu2018 母牛的故事(模拟)
鹅厂机器狗花式穿越10m梅花桩:前空翻、单桩跳、起身作揖...全程不打一个趔趄
Why do programmers only close monitor from none computer after work?Look at the answer ~ each big web site
Goose Factory Robot Dog Fancy Crossing 10m Plum Blossom Pile: Front Flip, Single Pile Jump, Get Up and Bow... No stumble in the whole process
什么是Shell?从小白到入门你只差一个它
腾讯云原生成本优化平台FinOps Crane荣获国家级大奖!
PyTorch入门:(一)数据加载
使用 lua 运行 fscript
如何在Firewalld中为特定IP地址开放端口
Why Manufacturing Companies Should Deploy Digital Factory Systems
重读GPDB 和 TiDB 论文引发的 HTAP 数据库再思考
Rethinking HTAP database caused by rereading GPDB and TiDB papers
在Unity URP中实现Forward+
工程 (六) ——PointNet点云分类
golang流程控制:if分支、switch分支和fallthrough switch穿透
从 VLAN 到 IPVLAN: 聊聊虚拟网络设备及其在云原生中的应用
A Preliminary Study on Pannellum, a Lightweight Panorama Viewer
PyTorch入门:(四)torchvision中数据集的使用
Word清除格式在哪里?Word清除格式使用方法
hdu2647 N!Again