Qt Creator中从属文件的自动复制 [英] Automatic Copy of Dependent Files in Qt Creator
问题描述
我使用Qt Creator 2.2.1和Qt 4.7.4(32位)构建了一个程序,它的输出是一个可执行文件。使用DependencyWalker打开exe它显示exe使用以下DLL:
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
- KERNEL32.DLL
- MSVCRT.DLL
- MINGWM10.DLL
- LIBGCC_S_DW2-1.DLL
- QTCORE4.DLL
- QTGUI4.DLL
我想在构建所有依赖文件在某些其他项目中可能有所不同),除了Windows特定的文件(上面列表中的前两个)在exe所在的目录中自动复制。
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.
如何在Qt Creator或Qt系统中,而无需使用命令行脚本?感谢。
How can I do it in Qt Creator or Qt system without using command line scripting? Thanks.
推荐答案
在QT 5.3中,您可以使用 windeployqt
qt工具自动复制所需的库。
In QT 5.3, you may be able to use the windeployqt
qt tool to automatically copy the needed libraries.
以下对项目的.pro文件的补充应该能做到这一点,但你可能需要根据您的特殊情况。
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.
isEmpty(TARGET_EXT) {
win32 {
TARGET_CUSTOM_EXT = .exe
}
macx {
TARGET_CUSTOM_EXT = .app
}
} else {
TARGET_CUSTOM_EXT = $${TARGET_EXT}
}
win32 {
DEPLOY_COMMAND = windeployqt
}
macx {
DEPLOY_COMMAND = macdeployqt
}
CONFIG( debug, debug|release ) {
# debug
DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/debug/$${TARGET}$${TARGET_CUSTOM_EXT}))
} else {
# release
DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/release/$${TARGET}$${TARGET_CUSTOM_EXT}))
}
# # Uncomment the following line to help debug the deploy command when running qmake
# warning($${DEPLOY_COMMAND} $${DEPLOY_TARGET})
# Use += instead of = if you use multiple QMAKE_POST_LINKs
QMAKE_POST_LINK = $${DEPLOY_COMMAND} $${DEPLOY_TARGET}
这篇关于Qt Creator中从属文件的自动复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!