The Big Picture: A Chain of "I Need"

A program needs a DLL. But that DLL is also made of code, and it may need other DLLs too. And those may need more. Like a recipe that says "use the sauce from page 40", and page 40 says "start with the stock from page 12".

If one link in this chain is missing, the whole thing fails.

6.1 Dependency Chains: DLLs That Depend on DLLs

What it is: A dependency is something a file needs in order to work. DLL dependencies form a tree: the program is the root, its imports are branches, and their imports are smaller branches.

 myapp.exe
  ├── kernel32.dll
  │     ├── kernelbase.dll
  │     └── ntdll.dll
  ├── user32.dll
  │     ├── win32u.dll
  │     ├── gdi32.dll
  │     └── ...
  ├── vcruntime140.dll
  │     └── (system API-set DLLs)
  └── mylib.dll
        └── helper.dll   <-- if this is missing, mylib.dll fails,
                              and so does myapp.exe

(An example only. The exact tree differs by program and Windows version.)

Key facts:

  • The loader walks the whole tree before the program starts (Section 3.1).
  • The same DLL can appear on many branches. It is loaded once and shared.
  • Almost everything ends at ntdll.dll and kernel32.dll/kernelbase.dll.
  • API sets: you may see names like api-ms-win-core-.... These are virtual DLL names. Windows uses a built-in table to redirect each one to a real DLL, so programs can name a feature instead of a file. You will not find those files as normal DLLs on disk (or they may be tiny placeholders). Do not worry if you cannot see them. (Hedge: the details vary by Windows version.)

How to see the tree:

ToolWhat it shows
tasklist /mEvery loaded module for every process (a flat list)
Get-Process -Name x | Select-Object -ExpandProperty ModulesLoaded modules for one process, with paths
Process Explorer (Sysinternals), then Ctrl + DA DLL view for the selected process
dumpbin /dependents fileThe DLLs a file directly imports (needs Visual Studio tools; optional)

Windows-specific tip: To see the direct needs of one DLL, dumpbin /dependents works. To see everything loaded in a running program, use the others. The first shows what is declared; the others show what actually happened.

6.2 Missing Dependency Errors

What it is: When the loader cannot find a needed DLL (or the right function in it), the program stops and Windows shows an error. You have probably seen one:

The code execution cannot proceed because XYZ.dll was not found. Reinstalling the program may fix this problem.

Another form is:

The procedure entry point FunctionName could not be located in the dynamic link library XYZ.dll.

Older Windows said "The program can't start because XYZ.dll is missing from your computer."

What these mean:

MessageWhat happened
"... was not found"The loader searched all places (Section 4) and found no file with that name
"entry point ... could not be located"A file with that name was found, but it is a different version that does not export the function the program needs
"... is either not designed to run on Windows or it contains an error" (bad image)The file is the wrong type: a 32-bit DLL for a 64-bit program, or a damaged file
Error 0xc000007bA common code for a 32-bit and 64-bit mix-up (hedge: it can also have other causes)

Common causes:

  1. The program was copied from another PC instead of being installed, so its helper DLLs are missing.
  2. A runtime package is missing, for example the Visual C++ Redistributable. It installs shared files like vcruntime140.dll and msvcp140.dll. (Hedge: the exact file names change with Visual Studio versions.)
  3. The wrong version of a DLL is found first (Section 4, or "DLL hell" in Section 7).
  4. A security program quarantined (removed) a file.
  5. The wrong bitness (32 or 64) was installed.

How to fix it safely:

 1. READ the DLL name in the error.
 2. Is it part of a known package?
      vcruntime140 / msvcp140  -> install the official Microsoft
                                  "Visual C++ Redistributable" (x64 and x86)
      d3dx9_xx / xinput        -> the game's installer usually provides it
 3. Otherwise: REINSTALL the program (puts its DLLs next to the EXE).
 4. Run:   sfc /scannow     (repairs damaged Windows system files;
                              needs an administrator window)
 5. Check Windows Update.

Never download a single DLL from a random "free DLL" website. These files are often fake or carry malware, and they bypass Windows's checks. Always use the official installer or Microsoft's own download page.

Checking where a DLL comes from: To find out whether a file is the one Windows expects:

Get-Command kernel32.dll | Select-Object Source
where.exe kernel32.dll

where.exe and Get-Command search the folders on your PATH. Note that this is for commands and files found through PATH. They are not a replica of the full DLL search order.

Summary

TopicRemember this
Dependency treeA DLL's own imports form a tree below the program; the loader loads all of it
API setsVirtual api-ms-win-* names redirected by Windows to real DLLs
"Not found" errorNo file by that name was found in any searched place
"Entry point not located"Right name, wrong version: the function is missing
Bad image / 0xc000007bWrong type or 32/64-bit mismatch
Safe fixReinstall the program, install the official redistributable, run sfc /scannow
NeverDownload lone DLLs from random websites