GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • OS Tutorial
  • Interview Questions
  • Quizzes
  • Notes
  • System Call
  • Paging
  • Virtual Memory
  • Deadlock Handling
  • DBMS
  • Computer Network
  • Digital Electronics
  • TOC
  • Operating System5 min read
  • Types7 min read

This view

  • Original page
  • New address

GeezerVison is showing www.geeksforgeeks.org — Difference between Static and Shared libraries - GeeksforGeeks

geeksforgeeks
search icon
  • Courses
  • Tutorials
  • Interview Prep
  • OS Tutorial
  • Interview Questions
  • Quizzes
  • Notes
  • System Call
  • Paging
  • Virtual Memory
  • Deadlock Handling
  • DBMS
  • Computer Network
  • Digital Electronics
  • TOC

Difference between Static and Shared libraries

Last Updated : 28 Jul, 2025

In programming, a library is a collection of pre-compiled pieces of code that can be reused in a program. Libraries simplify life for programmers, in that they provide reusable functions, routines, classes, data structures and so on which they can be reused in the programs. 

Static Libraries: A Static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable. This executable and the process of compiling it are both known as a static build of the program. Historically, libraries could only be static. They are usually faster than the shared libraries because a set of commonly used object files is put into a single library executable file. One can build multiple executables without the need to recompile the file. Because it is a single file to be built, use of link commands are simpler than shared library link commands, because you specify the name of the static library.

Shared Libraries: Shared libraries are .so (or in Windows .dll, or in OS X .dylib) files. These are linked dynamically simply including the address of the library (whereas static linking is a waste of space). Dynamic linking links the libraries at the run-time. Thus, all the functions are in a special place in memory space, and every program can access them, without having multiple copies of them.

propertiesStatic libraryShared library
Linking timeIt happens as the last step of the compilation process. After the program is placed in the memoryShared libraries are added during linking process when executable file and libraries are added to the memory.
MeansPerformed by linkersPerformed by operating System
SizeStatic libraries are much bigger in size, because external programs are built in the executable file.Dynamic libraries are much smaller, because there is only one copy of dynamic library that is kept in memory.
External file changesExecutable file will have to be recompiled if any changes were applied to external files.In shared libraries, no need to recompile the executable.
TimeTakes longer to execute, because loading into the memory happens every time while executing.It is faster because shared library code is already in the memory.
CompatibilityNever has compatibility issue, since all code is in one executable module.Programs are dependent on having a compatible library. Dependent program will not work if library gets removed from the system .
Comment

Explore

    Basics
    • Operating System5 min read
    • Types7 min read
    • Kernel3 min read
    • System Call2 min read
    • Boot Process3 min read
    Process Management
    • Process Management3 min read
    • CPU Scheduling7 min read
    • Process Synchronization3 min read
    • Synchronization Problem Solutions4 min read
    • IPC Problems2 min read
    • Deadlock2 min read
    • Handling Deadlocks2 min read
    • Multithreading4 min read
    Memory Management
    • Memory & Memory Units2 min read
    • Memory Management4 min read
    • Buddy System5 min read
    • Overlays4 min read
    • Virtual Memory7 min read
    • Page Replacement Algorithms5 min read
    • OS based Virtualization5 min read
    I/O Management
    • File Systems4 min read
    • Directory Management3 min read
    • Secondary Memory7 min read
    • Disk Scheduling9 min read
    • Spooling vs Buffering1 min read
    Important Links
    • Notes15+ min read
    • Interview Questions15+ min read
    Courses
    • Placement 360 Course2 min read
    • GATE CS-IT & DA Courses2 min read
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.