当前位置:网站首页>What are precompiled, compiled, assembled, linked, static and dynamic libraries

What are precompiled, compiled, assembled, linked, static and dynamic libraries

2022-06-11 08:52:00 Currybeefer

precompile :
Precompiling is also called preprocessing , Is to do some code text replacement work
Expand the header file , uncomment , Replace all macro defined symbols

compile :
Lexical analysis of the file , Syntax analysis , Semantic analysis , After symbol summary , Translate the code into assembly language ( Assembly language is MOV,ADD Things like that )

assembly :
Convert the file to binary file, i.e. target file , Each source file corresponds to a target file , stay windows The suffix of the target file in is .obj

link :
It's really just a “ pack ” The process of , It combines all binary object files and system components into an executable file . The process of completing the link also requires a special software , It's called a linker .

After the assembly , Each object file has not yet “ contact ” get up , A function or variable used in an object file , It may be defined in other object files , It may also be defined in a link library file . For the storage address of the missing functions and variables in each object file , In the linking phase, the linker , And finally organize all the target files and link libraries into an executable file . stay windows The next executable file is suffixed with .exe.

Link library :
The so-called link library , Is to compile some source files , Binary file after packaging . Although link libraries are binary files , But it cannot run independently , Must wait for other program calls , Will be loaded into memory . Library files often have a header file , It is convenient for programs that need to link this library to see how to call . Link libraries are divided into static libraries and dynamic libraries .

Static library :
Windows Middle suffix is .lib. Static libraries will be directly integrated into the target program during compilation , The packaged files can run independently anywhere . The file compiled from the static function library will be relatively large , If this static library is updated by , You need to recompile .

Dynamic library :
windows Middle suffix is .dll. Dynamic libraries are not integrated into the target program at compile time , The generated executable cannot be run alone . Therefore, there are still missing variables and functions in the compiled linked file , These defects will be fixed when the program is running . In particular , For a project that runs as a dynamic link , First, the static linker organizes all the target files into an executable file , The runtime will load all the required dynamic link libraries into memory , The dynamic linker completes the linking of executable files and dynamic library files .
Dynamic link libraries can be loaded into memory along with executable files , You can also load... While the executable is running , When the executable file is needed , Dynamic link library will be loaded into memory .

For different libraries , What the linker does in the linking phase is different .
For static libraries , The linker will find the missing addresses in each target file one by one . The executable file generated by this link , It can be loaded into memory and run independently .
For dynamic libraries , The linker first finds some missing addresses from all the target files , Then organize all the target files into one executable file . The executable file thus generated , The addresses of some functions and variables are still missing , To be executed , It needs to be loaded into memory together with all link library files , Then the linker completes the remaining address repair work , Can be executed normally .

Reference link :
https://blog.csdn.net/yao00037/article/details/120166233
http://c.biancheng.net/dll/what_is_library.html

原网站

版权声明
本文为[Currybeefer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110844216103.html