Skip to content
The Computer Science
TheCScience
  • Engineering Subjects
    • Human Values
    • Computer System Architecture
    • Microprocessor
    • Digital Communication
    • Internet of Things
  • NCERT Solutions
    • Class 12
    • Class 11
  • Solutions
    • HackerRank
      • C Solutions
      • C++ Solutions
      • Java Solutions
      • Python Solutions
      • Algorithms Solutions
      • Data Structures Solutions
    • HackerEarth Solutions
    • Leetcode Solutions
  • JEE 2027
The Computer Science
TheCScience

Static and Dynamic Linking in Operating Systems | OS Tutorials

YASH PAL, June 13, 2026June 13, 2026

In operating systems, static and dynamic linking methods are used to combine an application program with the parts of various library routines it uses.

Table of Contents

  • Static Linking
    • Disadvantages of Static Linking
  • Dynamic Linking
    • Disadvantages of Dynamic Linking
  • When to use Dynamic Linking and Static Linking?
  • What is the Difference Between Dynamic Loading and Dynamic Linking?

Static Linking

  • Static linking is the original method used to combine an application program with the parts of various library routines it uses.
  • The linker is given your compiled code, containing many unresolved references to library routines. It also gets archive libraries (for example /usr/lib/libm.a) containing each library routine as a separate module.
  • The linker keeps working until there are no more unresolved references and writes out a single file that combines your code and a jumbled mixture of modules containing parts of several libraries.
  • The library routines make system calls directly, so a statically linked application is built to work with the kernel’s system call interface.

Disadvantages of Static Linking

  • The main problem with static linking is that the kernel system call interface is in itself a dynamic binding, but it is too low-level.
  • The performance problems with static linking arise in three areas.
    1. RAM wasted by duplicating the same library code in every statically linked process can be significant.
    2. A static-linked program contains a subset of the jumbled library routines. The library cannot be tuned as a whole to put routines that call each other onto the same memory page. The whole application could be tuned this way, but very few developers take the trouble.
    3. Subsequent versions of the operating system contain better-tuned and debugged library routines, or routines that enable new functionality. Static linking locks in the old slow or buggy routines and prevents access to the new functionality.

    Dynamic Linking

    When the linker builds a dynamically linked application, it resolves all the references to library routines, but it does not copy the code into the executable.

    Disadvantages of Dynamic Linking

    • From a performance viewpoint, there is “glue code” that is required in the executable program to access the shared segment. There is a performance cost in references to shared library routines of about eight machine cycles per reference.
    • Programs that use shared libraries are usually slower than those that use statically-linked libraries.
    • Reduction in “locality of reference.”
    • Dynamically linked programs are dependent on having a compatible library. If a library is changed (for example, a new compiler release may change a library), applications might have to be reworked to be made compatible with the new version of the library.
    • If a library is removed from the system, programs using that library will no longer work.

    When to use Dynamic Linking and Static Linking?

    • The operating system provides facilities for creating and using dynamically linked shared libraries.
    • With dynamic linking, external symbols referenced in user code and defined in a shared library are resolved by the loader at load time.
    • When you compile a program that uses shared libraries, they are dynamically linked to your program by default.
    • The idea behind shared libraries is to have only one copy of commonly used routines and to maintain this common copy in a unique shared-library segment.
    • These common routines can significantly reduce the size of executable programs, thereby saving disk space.
    • We can reduce the size of your programs by using dynamic linking. The shared library code is not present in the executable image on disk, but is kept in a separate library file.
    • Shared code is loaded into memory once in the shared library segment and shared by all processes that reference it.
    • Dynamically linked libraries therefore reduce the amount of virtual storage used by your program, provided that several concurrently running applications (or copies of the same application) use the procedures provided in the shared library. They also reduce the amount of disk space required for your program, provided that several different applications stored on a given system share a library.
    • In statically-linked programs, all code is contained in a single executable module. Library references are more efficient because the library procedures are statically linked into the program.
    • Static linking increases the file size of your program, and it may increase the code size in memory if other applications, or other copies of your application, are running on the system.

    What is the Difference Between Dynamic Loading and Dynamic Linking?

    • They are the same except that dynamic loading loads on demand and dynamic linking links on demand.
    • The operating system must be used in dynamic linking, as every process in the memory is protected from each other and the operating system is the only entity which can search for routines used by another process.
    • By dynamically loading something into something else, you are fusing sources together. In the overall output (if applicable), this may make syntax difficult to read.
    • By dynamically linking something to something else, you are creating a bridge that allows certain groups of sources to be categorized into different files – easily being able to access them, viewing by source or output.
    engineering subjects Operating System Operating System

    Post navigation

    Previous post

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Engineering Core Subjects

    Digital Communication Subject
    Internet of Things Subject
    Computer Architecture subject
    Human Value Subject

    JEE Study Materials

    JEE Physics Notes
    JEE Chemistry Notes

    TheCScience

    At TheCScience.com, our mission is to make quality education accessible to everyone. We provide in-depth, easy-to-understand articles covering Secondary, Senior Secondary, and Graduation-level subjects.

    Pages

    About US

    Contact US

    Privacy Policy

    DMCA

    Our Tools

    Hosting - get 20% off

    Engineering Subjects

    Internet of Things

    Human Values

    Digital Communication

    Computer System Architecture

    Microprocessor

    Programming Tutorials

    Data Structure and Algorithm

    C

    Java

    NCERT

    Class 12th

    ©2026 TheCScience | WordPress Theme by SuperbThemes