ArticleslgStudy

computer science

Shared library

Shared library is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Shared library rather than just read about it. In short: A shared library is a library of executable code that is loaded in memory such that multiple executables (programs and other libraries) can use it at runtime. In contrast, a static library is copied into an executable.

Key takeaways

  • Shared library belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Shared library to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Shared library from memory before moving on to harder problems.

Reference excerpt

A shared library is a library of executable code that is loaded in memory such that multiple executables (programs and other libraries) can use it at runtime. In contrast, a static library is copied into an executable. A static library can be re-used (a form of sharing) in multiple executables, but each executable contains a copy of the library code instead of sharing a copy in memory with other executables. Although not true today, historically, all libraries were static. Although a shared library can have static linkage, such a library is not classified as a static library. Often, a shared library is also a dynamic library loaded by a dynamic linker, which generally makes use of the library easier for the programmer than if it instead it had static linkage. A dynamic library need not be accessible to multiple executables (shared library) and a shared library need not be loaded at consumer runtime (dynamic library).

Memory sharing

Library code may be shared in memory by multiple processes and on disk. If virtual memory is used, processes would execute the same physical page of RAM mapped into the processes' different address spaces. This has advantages. For instance, on the OpenStep system, applications were often only a few hundred kilobytes in size and loaded quickly; most of their code was located in libraries already loaded for other purposes by the operating system. Programs can accomplish RAM sharing by using position-independent code, as in Unix, which leads to a complex but flexible architecture, or by using common virtual addresses, as in Windows and OS/2. These systems ensure that code has a high probability of being shared by various means, like pre-mapping the address space and reserving slots for each shared library. A third alternative is a single-level store with a single address space, as used by the IBM System/38 and its successors. This allows position-dependent code, with programs and libraries assigned a permanent address in that address space. In some cases, different versions of shared libraries can cause problems, especially when libraries of different versions have the same file name and various applications are installed on a system, each requiring a specific version. This scenario is known as DLL hell, named after the Windows and OS/2 DLL files. Most modern operating systems after 2001 have clean-up methods to eliminate such situations or use application-specific "private" libraries.

Examples The following commonly-used library technologies are both shared and dynamic in nature.

DLL Windows uses the Portable Executable (PE) format for its dynamic-link library (DLL) technology. SO Solaris and other System V Release 4-based systems, Linux, and current BSD systems use the Executable and Linkable Format (ELF) for the shared object (SO) technology, sometimes and more accurately called dynamic shared object (DSO). DYLIB Darwin-based operating systems, such as macOS and iOS, use the Mach-O format for .dylib files.

See also Loadable kernel module – Dynamically loadable module that extends a running operating system kernel

References

Sources Levine, J.R. (2000). Linkers and Loaders. Operating Systems Series. Elsevier Science. ISBN 978-1-55860-496-4. Retrieved 2025-02-02.

External links How To Write Shared Libraries Archived 2007-06-16 at the Wayback Machine by Ulrich Drepper

Worked examples

Example 1 — a first encounter with Shared library

Start with the simplest possible case. Write down what Shared library claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Shared library before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Shared library ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Shared library

In research
Shared library appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Shared library in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Shared library is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer libraries, Operating system technology, so understanding it makes those chapters shorter.
In everyday life
Look for Shared library outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Shared library” →

How to study Shared library in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Shared library means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Shared library out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Shared library in simple terms?

A shared library is a library of executable code that is loaded in memory such that multiple executables (programs and other libraries) can use it at runtime. In contrast, a static library is copied into an executable.

Why does Shared library matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Shared library?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Shared library.

Tags

  • Computer libraries
  • Operating system technology

Keep exploring