In addition to [WayBack] c++ – DLL Load Library – Error Code 126 – Stack Overflow while debugging LoadLibrary error 126
Windows dll error 126 can have many root causes. The most useful methods I have found to debug this are:
- Use dependency walker to look for any obvious problems (which you have already done)
- Use the sysinternals utility [WayBack] Process Monitor – Windows Sysinternals | Microsoft Docs from Microsoft to trace all file access while your dll is trying to load. With this utility, you will see everything that that dll is trying to pull in and usually the problem can be determined from there.
Search for the first entry NAME NOT FOUND
after your library is being loaded.
It indicates the module that cannot be found which indirectly causes error number 126 (ERROR_MOD_NOT_FOUND
in [WayBack] System Error Codes (0-499) – Windows applications | Microsoft Docs ) in [WayBack] LoadLibrary:
ERROR_MOD_NOT_FOUND
- 126 (0x7E)
The specified module could not be found.
This is why I upvoted the very relevant comment:
… when I looked at the rows surrounding my dll being loaded I saw MSVCP140D.dll was giving a result of
NAME NOT FOUND
. Turns out the machine that couldn’t load my dll doesn’t have the ‘D’ version of MSVCP140.dll. Everything worked when I built my dll for release! – [WayBack] Pakman.
–jeroen