Lefteris
Lefteris

Reputation: 3256

QT, including a .dll using QTEditor

I am new to using QT so I suppose this has an easy answer but it eludes me. I am porting an application into QT and I went about using the QTEditor to do that. My compiler is MinGw and QT version is 4.7.4 and the OS is Windows 7.

All happens fine in the compiling and linking. It is during running that I get the exit code 0xc0000135 which means a missing dependency. The dependency in question is a C library that I have made myself and is also compiled with mingw so there is no binary compatibility issue. In addition if I put the .dll in the same directory as the resulting executable the application runs fine.

Here is the relevant part of the .pro file:

win32:LIBS += C:\Projects_SourceCode\MyLib\Bin\Release\MyLib.dll
win32:INCLUDEPATH += C:\Projects_SourceCode\MyLib\

What am I missing? This compiles and links fine but later the executable fails to find the "MyLib.dll". I would like to avoid putting it in the path. Isn't there a way from within QTEditor to let the executable know where to search for the .dll?

I am used to using the Codeblocks IDE and from there it's really easy to do such a thing so I assume QTEditor also allows for such an option. Any help would be appreciated.

Upvotes: 2

Views: 274

Answers (1)

j_kubik
j_kubik

Reputation: 6181

You could add it to PATH variable only for running environment (not in entire system) - you can manipulate run environment in projects screen. Obviously this will work only for debugging, not for production executable. For distributing your app consider putting dll in the same dir as main executable.

Where to look for dll is (at least on windows) not written in executable - the system firstly looks in executable directory, and then looking through PATH directories, so you cannot do it any other way. Where to look for dll is a matter of execution, not compilation, so don't expect qmake project file to help you with it.

Upvotes: 1

Related Questions