← Back to list

Static Vs Dynamic Libraries

Library is a collection of precompiled functions and data that your program can reuse. Libraries Improve the modularity, reduce the code…

Naveen Nani · 2026-02-23 18:02 · 1 claps · 1.2 min read
#static-library #dll #windows #c
Open on Medium ↗
Wiki topics: 📚 · Books & Reading

Static Vs Dynamic Libraries

Library is a collection of precompiled functions and data that your program can reuse. Libraries Improve the modularity, reduce the code duplication and speed up development

  1. Static Libraries -> Linked at compile time
  2. Dynamic Libraries -> Linked at run time

Static vs Dynamic libraries

Static vs Dynamic libraries

Static library has its own text & data sections and maintains separate memory map for each process

Process A: — — — — — — — — — — — — — — — — - | App Code + Lib Code (TEXT) | | App Data + Lib Data | — — — — — — — — — — — — — — — — -

Process B: — — — — — — — — — — — — — — — — - | App Code + Lib Code (TEXT) | | App Data + Lib Data | — — — — — — — — — — — — — — — — -

Dynamic library will use shared text sections mapped once into physical memory and shared across all the processes and maintain its own copy of data sections

RAM: — — — — — — — — — — — — — — — — - | Shared Library TEXT (1 copy) | — — — — — — — — — — — — — — — — -

Process A: | App TEXT | | Private Lib DATA |

Process B: | App TEXT | | Private Lib DATA |

In Windows to build as DLL

#define FUNC_DECL __declspec(dllexport) WINAPI — It tells the compiler to export this function from DLL so other applications can use it


메타데이터
post_id
686f3fe4a707
slug
static-vs-dynamic-libraries-686f3fe4a707
url
https://medium.com/@naveennani_81244/static-vs-dynamic-libraries-686f3fe4a707
canonical_url
https://medium.com/@naveennani_81244/static-vs-dynamic-libraries-686f3fe4a707
author_url
https://medium.com/@naveennani_81244
status
ok
fetched_at
2026-06-24 11:06:28