PDA

View Full Version : Library (.dll) found but not loading when running outside Qt Creator



ucomesdag
22nd March 2010, 12:34
Hi,

I'm using the latest SDK with Qt 4.6.2. I got all (5 in total) but one library (.dll) loading. When running from Qt Creator it loads fine but when running outside it doesn't get loaded.

QLibrary::errorString() gives me: "Cannot load library ./weblord.dll . The specified module could not be found."
and QFile::exists() finds the library ./weblord.dll. All loaded libraries have the same path (./libname.dll)

On Linux it loads all libraries fine. All libraries are in the root with the executable.

Has someone an idear what might be going on.

In Qt 4.5.3 it was all running fine, I cleaned out the project and reran qmake and it compiles without any warning or errors.

squidge
22nd March 2010, 12:58
On windows, remove the "./" to have the OS search the current directory first. Or you could change your path environment variable.

ucomesdag
22nd March 2010, 13:56
On windows, remove the "./" to have the OS search the current directory first. Or you could change your path environment variable.
Changing the path doens't make the library load but doesn't affect the other libraries either, they still load.
Why should I change any environment variables?
I suplied the path of the library, and it works fine for all 4 other libraries in the same directory.

I tried something else I renamed another library to weblord.dll and it loads fine. So maybe the library is corrupted. strange I don't get any errors or warnings when compilling. Also strange it runs fine from Qt Creator and not outside....

ucomesdag
22nd March 2010, 23:35
How can I check if my dll is valid? At runtime it is found, but not loading with a vague message "Cannot load library" and "The specified module could not be found". While before and after the call QFile finds the file????
My deduction is that something is wrong with the library. I didn't change any code. I just upgraded to QT 4.6.2 (SDK) (and yes I completely cleaned out the project and compiled it from scratch).

ucomesdag
11th May 2010, 15:25
Problem solved with Qt Beta 4.7

Robbie
18th June 2010, 21:13
I had a similar problem where a DLL was loading when I was running the application in VS and giving me an error when running from the command prompt.

I found that the problem was not that Windows couldn't find the DLL itself to load but rather one of its dependencies. Use the Dependency Walker (http://www.dependencywalker.com/) to find which file should be copied to your application directory.

I'm assuming the reason that the application was running in VS was because the dependent DLL (in my case QtSql.dll) was being referenced in a library path by VS that was not in my console's path.