Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

A dynamic-link library (DLL) is a Windows file containing code and data that programs can load and use. Instead of copying every library function into each program, Windows can link a program to the DLL when the program starts or let the program load it later while running.

What a DLL does

A DLL is a separate module that can provide functions and data to one or more programs. Keeping the library separate supports code reuse: programs can call its exported functions without each containing its own copy of that library code. Microsoft describes dynamic linking as including the information needed to locate an exported DLL function at load time or run time in its Windows DLL overview.

A DLL does not normally run as its own process. Windows maps it into the address space of the process that loads it; its functions run in that process and use the calling thread’s context and stack.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How Windows links a program to a DLL

Windows programs commonly use one of two approaches. The main difference is whether the DLL is required as the program starts or selected by the program later.

Approach When loading happens Build-time setup If the DLL is unavailable
Load-time dynamic linking Windows locates and loads required DLLs as the application starts. The build generally uses an import library. A missing required DLL can prevent the application from starting.
Run-time dynamic linking The application chooses whether and when to load a DLL during execution. An import library is not required for this explicit loading approach. The application can check for failure and provide an error or fallback.

Load-time dynamic linking

At build time, the developer typically provides an import library containing information about DLL functions the program uses. When Windows loads the application, it finds the required DLLs, maps them into the process, calls their entry points, and resolves the function addresses. Calls can then look much like ordinary function calls. If Windows cannot find a required DLL, the application may fail during startup. See Microsoft’s load-time dynamic linking documentation.

Run-time dynamic linking

With run-time linking, the application requests a DLL when it needs it, using LoadLibrary or LoadLibraryEx. It checks whether loading succeeded, then uses GetProcAddress to find an exported function and calls it through the returned address. When finished, it can call FreeLibrary to release its reference. This approach lets an application keep running if an optional DLL is unavailable and choose a fallback or report the problem; Microsoft notes that run-time dynamic linking can allow a process to continue without a DLL. Details are in Microsoft’s run-time dynamic linking documentation.

What happens when a DLL is loaded

Each process has its own reference count for a DLL. When a process loads the module, Windows maps it into that process; a run-time-loaded DLL can be unloaded from the process when its reference is no longer needed and the count reaches zero. This does not mean Windows starts a separate program for the DLL: its code executes within the process that loaded it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why a program might load the wrong DLL

Windows searches for DLLs according to the application type and loader configuration. The search is not one universal list: packaged and unpackaged applications can follow different rules, and factors such as already loaded modules, known DLLs, API sets, package dependencies, search flags, and configuration affect resolution. For an unpackaged app using the standard search order with safe DLL search mode enabled, the application directory comes before Windows system locations, while the current directory and PATH appear later. Consult Microsoft’s current DLL search order documentation for the applicable case.

If an untrusted party can control a directory Windows searches, a malicious DLL placed there could be loaded in place of the intended one. Microsoft’s DLL security guidance recommends practices such as using fully qualified paths where possible and controlling search locations with documented APIs and flags. A missing-DLL message alone is not a reason to download a DLL from an arbitrary website.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

DLLs, static libraries, and other files

A static library is linked into a program at build time, so the needed library code is copied into the resulting executable or module. A DLL remains a separate module that Windows locates and links at load time or that the application loads explicitly while running. A DLL can be shared as a module by multiple programs, though each process loads it into its own address space.

“DLL” is Windows terminology and refers to the Windows library module format; it is not a universal file format used by every operating system. Also, a .NET assembly may have a .dll or .exe extension but is internally different from a Win32 DLL. The extension alone does not establish that two files have the same structure or behavior.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.