Error when trying to load DLL with QLibrary
-
@Linhares said in Error when trying to load DLL with QLibrary:
QLibrary myLibrary("./myDll");
You are using a relative path: are you sure the lib is in the current working directory?
-
@Linhares said in Error when trying to load DLL with QLibrary:
"Cannot load library .\myDll: Unknown error 0x000000c1."
(Additional to @jsulm.) Most (in fact I think it is mandatory?) Windows DLL files end in
.DLL
... ?EDIT
Given the errorCannot load library .\myDll: Unknown error 0x000000c1
that might it is found, somehow, but is "not acceptable". Googledll Unknown error 0x000000c1
, seems to only come from Qt programs, e.g. see Cannot load library *.dll Unknown error 0x000000c1The error list you need is here. The symbolic name for that error is ERROR_BAD_EXE_FORMAT, and the error message is <filesoandso> is not a valid Win32 application. The DLL you're trying to open is either corrupt, or - most likely - it is for a different architecture. If you're compiling for 32 bits, use 32-bit DLLs. If you're compiling for 64 bits, use 64-bit DLLs.
If the developer says it is 32-bit are you compiling your Qt program 32-bit or 64-bit? :)
-
@Linhares Take a look at this: https://stackoverflow.com/questions/61080829/cannot-load-library-dll-unknown-error-0x000000c1
Is it possible that this DLL is built for a different architecture? Like your app is x86_64, but the lib x86. -
@Linhares
Although you have said "Yes, the lib is in the folder", and presumably you claim the relative path./myDll
finds it successfully, you still have not said anything about myMost (in fact I think it is mandatory?) Windows DLL files end in
.DLL
... ?? [Oh, are we supposed to guess that you are in fact not using literal
./myDll
but rather./something.dll
??] You could always do aQFileInfo
on whatever you pass to make sure....Otherwise @mchinand's suggestion of quickly making your application actually try to link with
thedll.lib
(you do have that?) by calling a function in it from your Qt program is a good idea to get a better error message, -
It turned out that I noticed I was being fooled by Qt Creator. Although the settings showed MSVC 32-bit as default, it was not installed. Hence, I was running a 64-bit compiler and thinking I was using a 32-bit one.
Thank you guys for the help with this! -