A linker is a system program that combines object files and required library files to create a single executable program.
A linker is a system program that combines object files and required library files to create a single executable program.
After a program is compiled and assembled, the linker joins the required pieces together and prepares the final executable program.
A large program may be divided into multiple source files and may use functions from libraries. The linker combines these separate parts so that the complete program can be executed.
| Item | Description |
|---|---|
| Input | Object files and required library files. |
| Processing | Combines modules and resolves external references. |
| Output | A single executable file. |
In static linking, the required library code is included in the executable file during the linking process.
In dynamic linking, some library code is linked at runtime using shared library files.
| Static Linking | Dynamic Linking |
|---|---|
| Library code is included in the executable. | Shared library code is linked when required. |
| Executable can be larger. | Executable can be smaller. |
| Less dependence on external libraries at runtime. | Depends on required shared libraries being available. |
Suppose a C program uses a library function such as
printf(). After compilation and assembly, the linker
connects the required library information with the object code
to create the final executable program.
Linker = Combines object files + libraries → Executable
| Point | Remember |
|---|---|
| Input | Object files + libraries |
| Main Job | Combines modules and resolves references |
| Output | Executable file |
| Types | Static linking and Dynamic linking |
Watch an easy explanation of linker and the program translation process.
A short handwritten-style revision sheet for Linker will be provided here.
Use the mind map for quick revision of linker, object files, libraries and executable generation.