Multiple choiceQuestion 1 · Recall
Loading…
By the end you can explain what a program library is, why developers use one, and what a DLL does differently from code copied in at compile time.
A program library is a collection of pre-written, ready-to-use routines — code for common jobs such as reading a file, drawing a window, sorting a list or calculating a square root.
Instead of writing that code again, a developer calls the library routine. Software under development is very often built from existing code in this way.
Think of it as cooking with ready-made stock instead of boiling bones every time. You still choose the recipe; you just do not redo the boring part.
There are two ways the library code reaches your program.
| Static library | Dynamic Link Library (DLL) | |
|---|---|---|
| When the code is joined | At compile time, copied into the executable | At run time, loaded when needed |
| Executable size | Larger (the code is inside it) | Smaller (code stays in the DLL) |
| Sharing | Each program has its own copy | One copy in memory can be shared by several programs |
| Updating | Recompile the program | Replace the DLL, and every program using it gets the fix |
| Risk | None beyond the program itself | If the DLL is missing, the wrong version or corrupted, the program fails ("DLL not found") |
A DLL is a dynamic link library: it is linked to the program when the program runs, not when it is compiled.
Worked example: Worked example: which approach, and why
A team is writing a photo editor. It needs routines to read JPEG files, and 12 other programs on the same machine also use those routines.
Should the JPEG code be in a static library or a DLL? Give two reasons.