---
title: "Role of linker"
subject: "Computer Programming"
chapter: 1
key: "semester_1/computer_programming:role-of-linker"
source: https://www.bctengineer.com/q/semester_1/computer_programming/role-of-linker
site: BCT Engineering
---

# Role of linker

Computer Programming · Chapter 1: Overview of computer software & programming languages

- Asked in: 2069 Chaitra, 2 marks
- Video: [Compiling, assembling, and linking](https://www.youtube.com/watch?v=N2y6csonII4) — EngMicroLectures
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/role-of-linker
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-1

## Question

Explain the role of linker.

## Short answer

A linker combines one or more object files with required library routines to produce a single executable file. It resolves external references, assigns final addresses, and reports errors like undefined references.

## Answer

A **linker** is a system program that combines one or more object files with the library routines they use and produces a single executable file.

Its roles are:
- Joins the object code of the main program, other modules and library functions (for example `printf` from the C library).
- Resolves external references, so a function call in one module is connected to its definition in another.
- Assigns final relative addresses to the combined code and data.
- Reports an error such as "undefined reference" when a function used is not found.

Flow: source (`.c`) -> compiler -> object (`.obj`) -> **linker** (+ libraries) -> executable (`.exe`).

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. The linker
   A. translates source into object code
   B. combines object files with library routines to produce one executable
   C. loads the program into RAM
   D. edits the source code
   Answer: B. The linker joins object files and libraries into an executable. (Key point: Linker purpose)

2. Resolving external references means
   A. removing syntax errors
   B. converting binary to assembly
   C. connecting a function call in one module to its definition in another
   D. deleting unused variables
   Answer: C. The linker connects calls to definitions across modules. (Key point: External references)

3. A misspelled function name such as prntf typically gives which message?
   A. syntax error: missing semicolon
   B. division by zero
   C. out of memory in editor
   D. undefined reference
   Answer: D. The linker cannot find the function and reports undefined reference. (Key point: Linker error)
