PDA

View Full Version : DLL won't load



waynew
24th October 2010, 21:35
I compiled a 3rd party library (developing on Windows) to create the dll.
To my knowledge it is not dependent on any other dll, since it is built using the static libraries it needs, expat, zlib, and openssl, all of which I compiled to create the .a files. The dll creates with no errors.

The problem is the dll won't load for my Qt application.
Here is the code:


QLibrary tqsllib2;
tqsllib2.setFileName("c:/cpp/qt_projects/hrlogger_development/debug/tqsllib2.dll");
tqsllib2.load();

qDebug() << "is tqsllib2 loaded ? " << tqsllib2.isLoaded();
qDebug() << "lib load error is " << tqsllib2.errorString();

The debug returns:
is tqsllib2 loaded ? false
lib load error is "Cannot load library c:/cpp/qt_projects/hrlogger_development/
debug/tqsllib2.dll: "

If I try to load a test dll using the above code, like a small one from the Windows/system32 directory, it loads fine. I realize this is not a Qt issue, but am hoping someone with more experience at this might be able to give me some suggestions as to what is going wrong.

Edit: If I point the setFileName to the original directory where the dll was created, the error message changes slightly:
lib load error is "Cannot load library c:/mingw/msys/1.0/home/wayne/tqsllib/tqs
llib2.dll: The specified module could not be found."

wysota
24th October 2010, 22:59
Use Dependency Walker on your dll to see its requirements.

waynew
24th October 2010, 23:11
Thanks Wysota. It's telling me there are problems with the dll

Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

I'll go back to the configure/build log and see if I can figure out what is missing.

wysota
24th October 2010, 23:23
You don't have to figure out anything. Dependency Walker has a list of dependencies and marks which ones are unresolved.

waynew
24th October 2010, 23:44
Yep, I found that. Looks like it wants 2 dlls that usually come with Vista, but not XP.
Got the dlls and building the library again.
Thanks.

schnitzel
25th October 2010, 01:35
it depends (no pun intended)... the output from depends needs to be interpreted on a case by case basis. I don't find it that straightforward to use (I like ldd in linux way better) - or I'm just not as bright.

For example if I run it on my app that runs just fine, it reports two errors and two warnings.
The two errors are deep down the tree for QTCORE4.dll:
IESHIMS.dll
WER.dll
Those two files can't be found and it is the same two DLLs no matter what executable I try to open.

The two warnings are:
At least one delay-load dependency module was not found.
At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

waynew
25th October 2010, 01:48
Thanks for reporting your experience Schnitzel - those are exactly the dlls Dependency Walker was complaining about.
Evidently they come with Vista, but not XP.
So I downloaded them and rebuilt the library. DW reports no missing dlls now, but it still gives me the same 2 errors you mentioned.

However, the library dll still refuses to load. I also have the application that uses that library installed on my development machine. So I tried loading the library from the application directory and it won't load either.

Maybe it's just something incompatible between this library and Qt. Not being an experienced C/C++ developer, I am lost now.
No idea as to how to make this work.

schnitzel
25th October 2010, 02:05
does the library come with examples?
do you have the full source?

why are you even explicitly trying to load the library?
Simplify your test case, i.e. write a simple app that only uses one method (such as an open or init call) in the dll.

waynew
25th October 2010, 02:48
Unfortunately, no. It comes with a binary application that uses the library and the library.


Yes.


Just to make sure it loads ok before I try to use some of the functions in it.

I haven't even tried using any of the functions in it yet since it won't load.
It's fairly large, but I only need a few functions. If I can't get this to work, the alternative is to export some data from my app, then have the user open the other app (the one that uses the library), then process the data from there. But it would be much more convenient for the user if they can process the data from my app.

I just don't understand why the library won't load. Even the version that their app builds when you install it won't load into my Qt app.
This is very perplexing to me.