Nika_Rika
Nika_Rika

Reputation: 627

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?

Upvotes: 1

Views: 1558

Answers (1)

Benjamin T
Benjamin T

Reputation: 8311

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

  • you need to have in the same folder (or in your PATH) at least Qt5Core.dll and Qt5Gui.dll and make sure
  • use the same compiler (version and architecture) for your software than the one used to build Qt
  • you might also want to use the debug versions of Qt DLLs (Qt5Widgetsd.dll, etc.) if you are building your soft in debug.

Upvotes: 3

Related Questions