Junior — Middle
What is the role and tasks of a linker in the program build process?
sobes.tech AI
Answer from AI
The linker is a build stage that combines compiled object files (.o, .obj) and libraries into a single executable or library.
Main tasks of the linker:
- Combining multiple object files into one executable.
- Resolving external references: linking function calls and variable references with their definitions.
- Allocating memory addresses for code and data.
- Including necessary libraries and modules.
Example: if a function is declared in one file but called in another, the compiler doesn't know where its code is. The linker connects the call with the actual function code.
Without the linker, the program cannot work correctly because it won't know where all parts of code and data are located.