DLL Load Error
Delphi Programming Language
Severity: CriticalWhat Does This Error Mean?
A DLL load error means Windows could not load a required DLL — either because it is missing, in the wrong location, has an incompatible architecture (32-bit vs 64-bit), or has missing dependencies of its own. If the DLL is declared with external and the load fails at startup, the application cannot run at all. The fix is to ensure the DLL is present, correctly named, in the right path, and matches the application's target architecture.
Affected Models
- Delphi 10.4 Sydney
- Delphi 11 Alexandria
- Delphi 12 Athens
- Embarcadero RAD Studio
- Free Pascal / Lazarus
Common Causes
- The DLL file is not present in the application folder, system folder, or any directory in the system PATH
- The DLL is 32-bit but the application is compiled as 64-bit (or vice versa)
- The DLL has its own dependencies (other DLLs) that are also missing
- The DLL requires a Visual C++ runtime or other redistributable that is not installed
- Using LoadLibrary with an incorrect or relative path that resolves to the wrong location
How to Fix It
-
Run Dependencies (open source tool) or the classic Dependency Walker on your executable to see exactly which DLLs are missing. It lists all direct and indirect dependencies.
Download 'Dependencies' (modern Dependency Walker replacement) from github.com/lucasg/Dependencies. It is free and shows the full dependency tree.
-
Copy the missing DLL to the application folder. The application folder is always searched first and is the safest deployment location.
Do not copy DLLs to the Windows System32 folder — place them in the application folder. System32 is for system DLLs only.
-
Check architecture. A 64-bit Delphi application cannot use a 32-bit DLL and vice versa. Rebuild the DLL or the application to match the same target platform (32-bit or 64-bit).
In Delphi, use Project → Options → Target Platforms to select Win32 or Win64. The DLL must match the selected platform.
-
If the DLL requires a Visual C++ runtime, install the correct version of the Microsoft Visual C++ Redistributable. Many third-party DLLs depend on specific MSVCRT versions.
The correct redistributable version is usually documented by the DLL vendor. For silent installation, include it in your installer.
-
Switch from static to dynamic loading for non-critical DLLs. Use LoadLibrary and check the result: H := LoadLibrary('mydll.dll'); if H = 0 then ShowError(SysErrorMessage(GetLastError));
Dynamic loading lets the app start and show a meaningful error message instead of a hard crash. GetLastError returns the Windows error code explaining why LoadLibrary failed.
When to Call a Professional
DLL load failures are critical — if the DLL is declared statically (external 'mydll.dll'), the application cannot start at all. Use Dynamic DLL loading (LoadLibrary + GetProcAddress) for non-essential DLLs so the app can start and report the error gracefully. Dependency Walker or the free Dependencies tool can show exactly which DLL or sub-dependency is missing.
Frequently Asked Questions
What is the difference between a static and dynamic DLL load in Delphi?
Static loading uses the external keyword in a function declaration — the DLL is loaded automatically when the application starts, and the app fails to start if the DLL is missing. Dynamic loading uses LoadLibrary at runtime — the app can start without the DLL and handle the missing case gracefully. Use dynamic loading for optional features or when the DLL may not always be present.
The DLL exists in the folder but still fails to load — why?
The DLL itself may have missing dependencies. Windows loads all dependencies of a DLL when loading it — if any dependency is missing, the whole load fails. Run the Dependencies tool on the DLL itself (not just your executable) to find what the DLL depends on.
Error 193 from LoadLibrary — what does it mean?
Error 193 (%1 is not a valid Win32 application) means you tried to load a 64-bit DLL into a 32-bit process or a 32-bit DLL into a 64-bit process. The application and all its DLLs must be the same architecture. Recompile either the DLL or the application so the architectures match.