The Microsoft gflags tool will always tell you exactly what dependency is failing to load and why.
Run gflags -i your_application.exe +sls
. After that execute the application under the debugger to capture the loader traces.
gflags is part of Debugging Tools -- you might check in C:\Program Files (x86)\Windows Kits\10\Debuggers\x64
to see if you already have it. You can add that directory to your path, or just execute gflags from that directory in cmd.exe.
For example, after running gflags, put a break point on the ::LoadLibrary(_T("foo"))
call and step over it while looking for loader errors in your Visual Studio output window, e.g.
4b00:396c @ 479194074 - LdrpSnapThunk - ERROR: Procedure "?SetObject@vis_DollarMap@@QEAAXHPEAX@Z" could not be located in DLL "bar.dll"
First-chance exception at 0x0000000077307EF8 (ntdll.dll) in your_application.exe: 0xC0000139: Entry Point Not Found.
4b00:396c @ 479194074 - LdrpGenericExceptionFilter - ERROR: Function LdrpSnapIAT raised exception 0xc0000139
Exception record: .exr 0000000000129070
Context record: .cxr 0000000000128B80
4b00:396c @ 479194074 - LdrpHandleOneOldFormatImportDescriptor - ERROR: Snapping the imports from DLL "C:\test\64Debug\foo.DLL" to DLL "C:\test\64Debug\bar.dll" failed with status 0xc0000139
This means that during the load of foo.dll
, the dependency bar.dll
was imported, and the bar.dll
import failed.
The dependency import failed because the procedure ?SetObject@vis_DollarMap@@QEAAXHPEAX@Z
was missing -- you can demangle that to public: void __cdecl vis_DollarMap::SetObject(int,void * __ptr64) __ptr64
.
You probably have the wrong version of a dependency -- maybe you need to rebuild the dependency to get it up to date.
Run gflags -i your_application.exe -sls
afterwards to disable the loader traces.