c++qtdllvisual-studio-2015loadlibrary

VS C++ LoadLibrary always returns null


VS2015 mfc project. Trying to load QT5Widgets.dll

CString sPath("M:\\ParseDLL\\Qt5Widgets.dll");
HMODULE hm = LoadLibrary(sPath);

hm is always null. I tried to change character set (unicode, multy bite), use _T, L before path text, changed win 32 to 64. Still nothing. GetlastErorr code 126 tells "The specified module could not be found". Dll is on this path. Any ideas?


Solution

  • Tt looks like a missing DLL. If M:\ParseDLL\Qt5Widgets.dll does exist, it means you are missing one of the DLL required by Qt5Widgets (or a DLL required by a DLL required by Qt5Widgets and so on).

    Like said by @Bathsheba, using a dependancy viewer tool can help you find the guilty DLL.

    Quick checklist