简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM