# Linker

> A tool that joins built pieces of code into one program.

**Field:** Software Development  
**Category:** Compilers & Runtimes  
**Also known as:** Linking, Link Step

## Think of it like

Think of it like stapling loose pages into one book. Each page was written on its own first.

## Definition

A linker is a tool that joins built pieces of code into one program you can run. A compiler often turns each source file into its own object file. These files call each other but do not yet know where the other parts are. The linker finds every call and connects it to the code it needs, including libraries. The result is one finished program file.

## Example

Jack's app has main.c and math.c. Each compiles to its own .o file. The linker joins them, and the program prints 5.

## Example code

```console
$ gcc -c math.c
$ gcc -c main.c
$ gcc main.o math.o -o app
$ ./app
5
```

Two files compile on their own, then one link step joins them into app.

## Why it matters

Big programs are built from thousands of files. Linking is what lets each one be compiled on its own.

## Common mistake

Reading an undefined reference error as a typo in your code. It means the linker could not find a file you forgot to add.

## Three principles

- **Pieces in.** Object files and libraries.
- **Calls connected.** Each to its code.
- **One program out.** Ready to run.

## Related terms

- [Compiler](https://learn.benibix.com/term/development/compiler)
- [Machine Code](https://learn.benibix.com/term/development/machine-code)
- [Software Library](https://learn.benibix.com/term/development/library)
- [Source Code](https://learn.benibix.com/term/development/source-code)
- [Executable File](https://learn.benibix.com/term/development/executable-file)

---

Source: https://learn.benibix.com/term/development/linker
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
