当前位置:网站首页>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
边栏推荐
- National standard gb28181 protocol video platform easygbs adds streaming timeout configuration
- 单场带货涨粉10万,农村主播竟将男装卖爆单?
- Implement your own dataset using bisenet
- opencv学习笔记四——膨胀/腐蚀/开运算/闭运算
- Virtual address space
- PLSQL的安装和配置
- [go ~ 0 to 1] obtain timestamp, time comparison, time format conversion, sleep and timer on the seventh day
- [hard core science popularization] working principle of dynamic loop monitoring system
- Grpc, oauth2, OpenSSL, two-way authentication, one-way authentication and other column directories
- The field value in Splunk subquery fuzzy matching CSV is*
猜你喜欢
Virtual address space
opencv学习笔记四——膨胀/腐蚀/开运算/闭运算
Coquette data completes the cloud native transformation through rainbow to realize offline continuous delivery to customers
Opencv learning notes II - basic image operations
一种适用于应用频繁测试下快速查看Pod的日志的方法(grep awk xargs kuberctl)
Obsidan之数学公式的输入
Opencv learning note 4 - expansion / corrosion / open operation / close operation
opencv学习笔记二——图像基本操作
Implementation of navigation bar at the bottom of applet
Lua programming learning notes
随机推荐
opencv学习笔记三——图像平滑/去噪处理
Exercise arrangement 2.10, 11
opencv学习笔记一——读取图像的几种方法
GOLand idea intellij 无法输入汉字
A single game with goods increased by 100000, and the rural anchor sold men's clothes on top of the list?
Interpreting the practical application of maker thinking and mathematics curriculum
Kotlin combines flatmap for filtering and zip merge operators
Bisenet features
The reified keyword in kotlin is used for generics
Splunk query CSV lookup table data dynamic query
2-3查找树
IELTS review progress and method use [daily revision]
Several ways of lambda used in functions in kotlin (higher-order functions)
Domain specific language / DSL in kotlin
SSM integration
接口作为参数(接口回调)
Using nocalhost to develop microservice application on rainbow
iptables 之 state模块(ftp服务练习)
[Chongqing Guangdong education] accounting reference materials of Nanjing University of Information Engineering
Opencv learning notes 1 -- several methods of reading images