PDA

View Full Version : Indicating to QtCreator the path to my dlls



Momergil
11th June 2014, 03:08
Hello!

Recently I changed the organization of one of my projects and after trying to run it again from Qt Creator, I got a startup message error saying that it couldn't run (not even QApplication was called in the main function). I did some research on the web and discovered that this was a problem I had encountered before: Qt Creator wasn't being capable of doing the linking with the dlls that are called at run-time.

I found that strange, because I thought that I did all the linking in the .pro file correctly not to mention I was using "QApplication::setLibraryPath" (which in this case wasn't useful since the code wasn't even going there). So I copied all the used dlls to the same place where the .exe was located and, after that, the problem vanished.

My question is: how can I tell Qt Creator to look for the .dlls in any place I want instead of always having to have a copy of each dll inside the same folder where my .exe is located? I guess it should be in the .pro file, but I don't know which command to use (LIBS += C:/Qt/Qwt-6.1.0/lib/qwtd.dll , for example, is not working for that); DEPENDPATH doesn't seems to be the case.

I'm glad for any help!

Thanks,

Momergil

anda_skoa
11th June 2014, 08:23
There are two times when an application needs to find the dynamic libraries: when you build it and when you run it.

The first usage is covered by LIBS, it should contain the path to a library and the name of the library, usually that will look like this



LIBS += -Lpath-to-library -lname-of-library-without-extension


This will allow qmake to generate the respective input for the built time linker.

The other usage is at start time, when the system's runtime linker needs to find the symbol that the libraries provide.
Each system has different rules how to find them, e.g. on Windows one of the search paths is the path the .exe is in.

Cheers,
_