Qt Creator 中依赖文件的自动复制
我使用 Qt Creator 2.2.1 和 Qt 4.7.4(32 位)构建了一个程序,其输出是可执行文件。使用 DependencyWalker 打开 exe,它显示该 exe 使用以下 DLL:
- KERNEL32.DLL
- MSVCRT.DLL
- MINGWM10.DLL
- LIBGCC_S_DW2-1.DLL
- QTCORE4.DLL
- QTGUI4.DLL
我想要在构建所有依赖文件后在其他项目中可能会有所不同),但 Windows 特定文件(上面列表中的前两个)会自动复制到所在目录exe 位于。
如何在不使用命令行脚本的情况下在 Qt Creator 或 Qt 系统中完成此操作?谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 QT 5.3 中,您也许可以使用
windeployqt
qt 工具自动复制所需的库。在项目的 .pro 文件中添加以下内容应该可以解决问题,但您可能需要根据您的具体情况进行一些调整。
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.
我将修改您的项目的 *.pro 文件并使用 安装。要真正移动文件,您需要运行
make install
。在 Qt Creator 中,您可以通过进入“项目”部分并添加新的构建步骤,将其添加为正常构建过程的一部分。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.即使不是完全自动的,您也可以使用 QtCreator 轻松完成您想做的事情。
将“INSTALLS”指令添加到您的项目(.pro)文件中(类似于jwernerny的建议):
在QtCreator(我的版本= 2.4.1)的“项目”选项卡中,您现在添加一个额外的构建步骤:
由于这些设置不会与项目文件一起保存,因此每次都必须执行第二部分(添加构建步骤)你创建一个新的构建配置(例如,发布和调试各一个)或将您的项目检出到新位置。
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.
不不不 0_o :)
在每个 .pro 文件中写入
DLLDESTDIR = ../../myproject/bin(...某些目录的结构...)
QMAKE_POST_LINK = Windeployqt --compiler-runtime $$DLLDESTDIR
DLLDESTDIR -- 文件名为 TARGET 的完整路径(dll 和 exe)。
结尾!
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!