当前位置:网站首页>Compilation and linking of programs
Compilation and linking of programs
2022-07-07 08:35:00 【WFForstar】
List of articles
One . preface
For normal application development , We need to pay little attention to the compilation and linking process , Because the usual development environment is a popular integrated development environment (IDE), such as Visual Studio、Delphi etc. . In this way IDE Generally, the process of compiling and linking is completed in one step , Usually, the The process of compiling and linking together is called building (Build ).
Command line to compile a source code file , A simple sentence **“gcc hello.c”**( The default output will be a.out This executable file ) The command involves a very complex process .
Two . The hidden process
1 . Linux The process of going on
#include<iostream>
int main()
{
std::cout << "Hello world" << std::endl;
return 0;
}
hello world This code is too classic , stay Linux Only the following steps are needed in
It's compiled .(a.out Is the name of the default executable )
As a matter of fact , The above process can be divided into four steps , Respectively :
Preprocessing , compile , assembly , link
2 . precompile
Precompiling mainly deals with those in the source code with “#” Precompiled instructions at the beginning , Such as “#include”#define" wait
Just use the command line as shown in the figure
Then you will find one more in the directory hello.i file , After opening, you will find .i There is no macro definition in the file
3 . compile
During the compilation process, the preprocessed files will be subjected to a series of lexical analysis , Grammatical analysis and , After semantic analysis and optimization, corresponding Assembly code file .
Just use the command line as shown in the figure
4 . assembly
The assembler converts assembly code into instructions that the machine can execute , Almost every assembly statement corresponds to a machine instruction , So the assembly process is very simple , There is no need to optimize .
Just use the command line as shown in the figure
5 . link ( Here, take static links as an example )
The time of static link is before the executable file is generated , So we need to use the command line to link duck .
In our actual development , It's not possible to put all the code in one source file , So there will be multiple source files , And multiple source files are not independent , And there will be multiple dependencies , If one source file may call a function defined in another source file , But each source file is compiled independently , each *.c The document will form a *.o file , In order to satisfy the dependency mentioned above , You need to link the target files generated by these source files , To form an executable program , The process of linking is static linking .
Just use the command line as shown in the figure
边栏推荐
- 下载和安装orcale database11.2.0.4
- 快速集成认证服务-HarmonyOS平台
- [Yu Yue education] higher vocational English reference materials of Nanjing Polytechnic University
- IP guard helps energy enterprises improve terminal anti disclosure measures to protect the security of confidential information
- A method for quickly viewing pod logs under frequent tests (grep awk xargs kuberctl)
- 详解华为应用市场2022年逐步减少32位包体上架应用和策略
- Deit learning notes
- 21 general principles of wiring in circuit board design_ Provided by Chengdu circuit board design
- Merge sort and non comparison sort
- [quick start of Digital IC Verification] 12. Introduction to SystemVerilog testbench (svtb)
猜你喜欢
Download and install orcale database11.2.0.4
Golang 编译约束/条件编译 ( // +build <tags> )
DeiT学习笔记
Famine cloud service management script
关于基于kangle和EP面板使用CDN
Low success rate of unit test report
Through the "last mile" of legal services for the masses, fangzheng Puhua labor and personnel law self-service consulting service platform has been frequently "praised"
Explore creativity in steam art design
Pvtv2--pyramid vision transformer V2 learning notes
Are you holding back on the publicity of the salary system for it posts such as testing, development, operation and maintenance?
随机推荐
[Yu Yue education] basic reference materials of electrical and electronic technology of Nanjing Institute of information technology
In go language, function is a type
MySQL introduction - crud Foundation (establishment of the prototype of the idea of adding, deleting, changing and searching)
Opencv learning note 4 - expansion / corrosion / open operation / close operation
[go ~ 0 to 1] obtain timestamp, time comparison, time format conversion, sleep and timer on the seventh day
opencv学习笔记一——读取图像的几种方法
DeiT学习笔记
IP guard helps energy enterprises improve terminal anti disclosure measures to protect the security of confidential information
数据中台落地实施之法
Several ways of lambda used in functions in kotlin (higher-order functions)
Domain specific language / DSL in kotlin
The reified keyword in kotlin is used for generics
Laravel8 uses passport login and JWT (generate token)
MES系统,是企业生产的必要选择
Wang Zijian: is the NFT of Tencent magic core worth buying?
Use of any superclass and generic extension function in kotlin
Interface as a parameter (interface callback)
Iptables' state module (FTP service exercise)
opencv学习笔记五——梯度计算/边缘检测
Train your dataset with swinunet