sodcalculator

10 Tech How-To

Fix LoadLibrary Failed Error 126 on Windows

Guide 10-35150 · Updated · Step by step

LoadLibrary failed with error 126 means Windows cannot find a required DLL or its dependencies when launching a program. The fix is to locate the missing or incompatible DLL, reinstall the application, or update the Visual C++ Redistributables, depending on what the error message names.

What Error 126 Actually Means

Error 126 is a system-level code that Windows returns when the LoadLibrary or LoadLibraryEx function fails. The number corresponds to ERROR_MOD_NOT_FOUND, which translates to “The specified module could not be found.” This is different from error 127 (ERROR_PROC_NOT_FOUND), which means the DLL was found but a specific function inside it was missing.

The error appears in several forms:

  • “The specified module could not be found.”
  • “LoadLibrary failed with error 126: The specified module could not be found.”
  • A dialog box from a specific program naming a DLL file.
  • An entry in the Windows Event Viewer under Application logs.

Importantly, the DLL named in the error is often not the real problem. A program may call LoadLibrary on a DLL that itself depends on another DLL. If any dependency in that chain is missing, Windows reports error 126 even though the named file exists. This is why simply downloading the named DLL from a random website is rarely a safe or effective fix.

Most Common Causes

Understanding why error 126 happens helps you choose the right fix. The usual triggers are:

  • Missing Visual C++ Redistributables — Many Windows programs rely on runtime libraries from Microsoft. If the required version (2015, 2017, 2019, 2022) is not installed, DLLs like msvcp140.dll or vcruntime140.dll are missing.
  • Corrupted or partially installed application — An interrupted update or a failed installation can leave the program’s DLLs incomplete.
  • Wrong architecture — A 32-bit program trying to load a 64-bit DLL, or vice versa, will fail with error 126.
  • Antivirus or security software — Some security tools quarantine or block DLLs they consider suspicious, especially after an update.
  • System file corruption — Windows system DLLs can become damaged after a crash or a failed update.
  • Path or environment issues — The DLL exists but is not in the search path Windows uses. This can happen when a program is moved or when the PATH variable is altered.

Step-by-Step Fixes to Try

Work through these in order, from least invasive to more involved. Stop when the error is resolved.

  1. Restart your computer. A simple reboot clears temporary file locks and can resolve issues caused by a partially completed update.
  2. Reinstall the application. Uninstall the program completely, then download a fresh copy from the official source and install it again. This replaces any corrupted DLLs that belong to the program itself.
  3. Install or repair the Visual C++ Redistributables. Go to Microsoft’s official download page and install both the latest x86 and x64 versions. If you already have them, run the repair option from “Apps & Features” in Settings.
  4. Run the program as administrator. Right-click the executable and select “Run as administrator.” This helps if the program needs to load DLLs from a protected folder.
  5. Check for a missing dependency with a DLL viewer. Tools like Dependency Walker (for older 32-bit apps) or the built-in dumpbin /dependents command can list what a DLL needs. Look for any entry that is not present in C:\Windows\System32 or the program’s folder.
  6. Run System File Checker. Open Command Prompt as administrator and run sfc /scannow. This checks and repairs protected system files.
  7. Temporarily disable antivirus. If the error started after a security update, disable real-time protection briefly and test the program. Re-enable it immediately after.
  8. Update Windows. Install all pending updates, then restart. This can replace outdated system DLLs.

How to Identify the Missing DLL

When the error message names a specific DLL, write it down. Then check whether that file actually exists on your system:

  • For 64-bit programs, look in C:\Windows\System32.
  • For 32-bit programs on 64-bit Windows, look in C:\Windows\SysWOW64.
  • Also check the program’s installation folder.

If the file is present, the problem is likely a dependency. If it is absent, do not download it from a third-party site. Instead, identify which software package normally provides that DLL. For example, msvcp140.dll comes from the Visual C++ 2015-2022 Redistributable. d3dcompiler_47.dll comes from DirectX. Reinstalling the correct package is safer than grabbing a random copy.

Why You Should Avoid “DLL Download” Sites

Many search results for error 126 lead to sites offering a direct DLL download. These are risky for several reasons:

  • The file may be outdated, causing a different error.
  • It may be the wrong architecture (32-bit vs 64-bit).
  • It could be bundled with malware or adware.
  • It will not fix missing dependencies, so the error often returns.

Microsoft’s official redistributables and the application’s installer are the only reliable sources for DLLs. If a program needs a specific DLL that is not part of a redistributable, the program’s own installer should have placed it there.

Special Case: Python and Other Scripting Environments

Error 126 is also common when loading Python extension modules (like numpy or pandas) or when using ctypes to load a custom DLL. In these cases:

  • Make sure the Python interpreter is 64-bit if the DLL is 64-bit, or vice versa.
  • Check that the DLL’s dependencies (often the Visual C++ Redistributable) are installed.
  • Use os.add_dll_directory() in Python 3.8+ to add the folder containing the DLL to the search path.
  • For Anaconda or Miniconda, run conda install -c anaconda vc to ensure runtime libraries are present.

When to Do a Clean Boot

If error 126 appears only when certain other programs are running, a software conflict may be the cause. A clean boot starts Windows with a minimal set of drivers and startup programs, helping you isolate the culprit.

  1. Press Win + R, type msconfig, and press Enter.
  2. Under the “Services” tab, check “Hide all Microsoft services” and click “Disable all.”
  3. Under the “Startup” tab, open Task Manager and disable all startup items.
  4. Restart and test the program. If it works, re-enable services and startup items one by one until the error returns.

Frequently Asked Questions

Why does error 126 appear even though the DLL is in the same folder as the program?

Windows does not automatically search the program’s folder for all DLLs. It uses a specific search order: the application’s folder, the system folders, the Windows folder, the current directory, and then the PATH environment variable. If the DLL is there but a dependency is missing, the load fails. Also, some programs load DLLs from a subfolder that is not in the search path.

Can I copy a DLL from another computer to fix this?

Copying a DLL from another machine can work if the source is the same version and architecture, and if you also copy all its dependencies. However, it is risky because system DLLs may be tied to a specific Windows version. It is almost always better to reinstall the software that provides the DLL.

Does error 126 mean my hard drive is failing?

No. Error 126 is a software-level error about a missing module. It does not indicate hardware failure. If you see the error consistently with many different programs, then system file corruption or a failing drive could be a secondary cause, but the error itself is not a hardware diagnostic.

Will updating Windows fix error 126?

Sometimes. Windows updates can replace outdated system DLLs and add new versions of the Universal C Runtime. If the error is caused by a missing system component, an update may resolve it. If the error persists after updating, the problem is more likely with the specific application or its redistributables.

Is error 126 the same as “DLL not found”?

Yes, in practical terms. Error 126 is the technical code for “module not found.” A program may display a friendlier message like “The code execution cannot proceed because X.dll was not found,” but the underlying error code is 126. The fix is the same.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →