Qt Project - application depending on a DLL file
-
Hi all,
i have a technical question about including some files into an executable project.
I explain :
i have a workspace which includes 2 projects.
The project 1 is creating a dll (thanks to several classes)
The project 2 is creating an .exe file : this soft is running if he get the dll in his path only.I'm a newbie in Qt from now, that's why i would be helped. That is my .pro file :
@
TEMPLATE = appCONFIG(debug, debug|release) {
TARGET = QMLEditord
} else {
TARGET = QMLEditor
}.
.
.win32:CONFIG(release, debug|release): LIBS += D:/acasini/hmi_workbench/libDeclarativeScriptParser/release/libDeclarativeScriptParser.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libDeclarativeScriptParser/debug/ -llibDeclarativeScriptParser
else:symbian: LIBS += -llibDeclarativeScriptParser
else:unix: LIBS += -L$$OUT_PWD/../libDeclarativeScriptParser/ -llibDeclarativeScriptParserINCLUDEPATH += $$PWD/../libDeclarativeScriptParser
DEPENDPATH += $$PWD/../libDeclarativeScriptParser
@All what i would like doing is running my .exe without the same error message : "XxXxX.dll is missing"
Thanks for your help :)
regards -
copy the generated dll into the same directory were you start the exe, or add the path to the dll to the PATH environment variable.
-
Hi, and thank you for you reply,
i have already found this solution, but the main drawback is that there is a dependancy between both project i have mentionned. Indeed, if for example there is happening a modification or an update in the DLL project, the "project 2" has to know it and adapt the new generated dll file "automatically".
So copy paste the dll into exe directory is not the solution. I think one of the best solution is to set to the INCLUDEPATH the path which leads to the DLL.
That is what i did :
INCLUDEPATH += $$PWD/../project1/release/myDLL.dll
But that does not work... Problem is i don't understand all tools in the .pro file, i have just started programming with Qt Creator this morning :/
Sorry if i look like stupid -
you do not need to include the DLL file into your project! the DLL file is the result and the compiler doesn't need know anything about the DLL file.
Instead the file which is interesting for the compiler are the *.a (mostly mingw32, gcc,...) and *.lib (MSVC, sometimes also unix, ...) files.
You are also NOT using the INCLUDEPATH variable correct in your project file!
Your pro-File should look like this:
@
INCLUDEPATH += ../testLib //path to the header files
LIBS+= -L../myDLL/debug -lmyDLL //path to the .a/.lib files
@The compiler mostly is able to look for the correct file extension, thus it should be sufficient to just supply -lmyDLL.
You said you have an error starting the exe which couldn't find the DLL, so copying the DLL to the exe is part of the distribution which is necessary to run the program.
-
mmm Okay...
Indeed, when i put the DLL file into exe directory i don't have any error, that's run alright.Thanks for explaining me differences between DLL and *a/*lib files, that is very useful !
I think i will just copy the DLL directly by a C++ function from project1 to project2,My problem is solved, thanks again for wasting your time for a begginer like me ;)
Cheers !
-
for this purpose you would be better off using QMAKE_POST_LINK, which will be executed after the build process has finished.
E.g. for windows:
@
win32:QMAKE_POST_LINK = copy <source-path>\*.dll <target-path>
@or alternatively call a bat file (shell script) which does everything you need after building finished.
-
that is the Qt command i have written in order to copy my DLL into my directory
@win32:QMAKE_POST_LINK = copy /Y $$PWD/../libDeclarativeScriptParser/release/libDeclarativeScriptParser.dll $$PWD/release@
But this does not work :/ it is strange, i have found many examples about it, and all used this command. But when i use it i don't have my DLL in my target directory :/
What if i used a "copy" function in my program ?
-
did you rerun qmake after you did add this line inorder to update the makefiles accordingly?
-
Sorry for my later reply
here is my command line :
@win32:QMAKE_POST_LINK = $${QMAKE_COPY} ../libDeclarativeScriptParser/release/libDeclarativeScriptParser.dll release/@When i run my qmake, there is showing an error
@The process "C:\QtSDK\mingw\bin\mingw32-make.exe" has been terminated - error code : 2@
-
Hi,
You have to give a more complete error log, this one doesn't say much
-
here are my errors
@mingw32-make: *** [release] Error 2
The process "C:\QtSDK\mingw\bin\mingw32-make.exe" has been terminated - error code : 2
step "Make" execution error@but i have no more logs :/
I don't have any error when i build the application without this "copy" command line -
Are you sure the paths are correct ?
-
When executing the copy, you might not be in the directory you think. Try to make something like:
@cd@in place of your current copy command to see where you are