I've build a program using Qt Creator 2.2.1 and Qt 4.7.4 (32 bit) whose output is an executable. Opening the exe using DependencyWalker it shows that the exe uses following DLLs:
- KERNEL32.DLL
- MSVCRT.DLL
- MINGWM10.DLL
- LIBGCC_S_DW2-1.DLL
- QTCORE4.DLL
- QTGUI4.DLL
I want after the build all dependent files (which may be different in some other project) except Windows specific files (the first two in the above list) to be automatically copied in the directory where the exe is located.
How can I do it in Qt Creator or Qt system without using command line scripting? Thanks.
No-no-no 0_o :)
In every .pro file write
DLLDESTDIR = ../../myproject/bin (... some dir's struct ...)
QMAKE_POST_LINK = windeployqt --compiler-runtime $$DLLDESTDIR
DLLDESTDIR -- full path with file name TARGET (dll and exe).
End!
In QT 5.3, you may be able to use the
windeployqt
qt tool to automatically copy the needed libraries.The following additions to the project's .pro file should do the trick, but you might have to make some adjustments based on your particular situation.
I would modify your *.pro file for the project and use INSTALLS. To actually cause the files to be moved, you will need to run
make install
. In Qt Creator, you can add it as part of your normal build process by going into the "Projects" section and adding a new build step.Even though not totally automatic, you can with little effort do what you want with QtCreator.
Add the "INSTALLS" directive to your project (.pro) file (similar to what was suggested by jwernerny):
In the "Projects" tab of QtCreator (my version=2.4.1) you now add an extra build step:
Since these settings are not saved with your project file you have to do the second part (Add Build Step) each time you create a new build configuration (e.g. one each for release and debug) or check out your project to a new location.