简体   繁体   English

C ++,Qt - 如何摆脱dll依赖?

[英]C++, Qt - How do I get rid of dll dependencies?

I have compiled my Qt application and now have the following question - now my built project requires QtCore4.dll and QtGui4.dll to be located at the same folder where the .exe file is. 我编译了我的Qt应用程序,现在有以下问题 - 现在我的构建项目需要QtCore4.dllQtGui4.dll位于.exe文件所在的同一文件夹中。 (I built my project using MSVS2008 with Qt addon) (我使用带有Qt插件的MSVS2008构建了我的项目)

Q: 问:

Is there any way to combine my final application with these .dll files so that they make one large .exe -file? 有没有办法将我的最终应用程序与这些.dll文件组合在一起,以便它们生成一个大的.exe文件? (I simply don't want to have another bunch of dll files with my release - app) (我根本不希望在我的发布版本中有另一堆dll文件 - 应用程序)

Thank you. 谢谢。

You need to build and link to Qt statically. 您需要静态构建链接到 Qt。

Edit: Here's an updated link to at least similar information . 编辑:这是至少类似信息的更新链接。

Bundle them into a self-extracting .exe (eg using 7zip) which extracts all files to a temporary directory, runs the program, then deletes the files after the program exits. 将它们捆绑成一个自解压的.exe(例如使用7zip),它将所有文件提取到一个临时目录,运行程序,然后在程序退出后删除文件。

This will be easier, less time consuming and less legally constraining than statically linking Qt as previously suggested. 与先前建议的静态链接Qt相比,这将更容易,更省时并且更少合法约束。

Of course you could statically link someway. 当然,你可以静态链接。 But the point of using DLL should be to make program smaller (both on disk and in memory, if other apps are using Qt libs of course)... DLL such as those should be systemwide so that other apps needing them can use them. 但是使用DLL的重点应该是使程序更小(在磁盘和内存中,如果其他应用程序当然使用Qt库)...那些DLL应该是系统范围的,以便其他需要它们的应用程序可以使用它们。 Basically you have to say to people wanting your program to work, to install the Qt framework. 基本上你必须对想要你的程序工作的人说,安装Qt框架。

Deploying the other way is explained here , read the part related to Static Linking. 这里解释部署其他方式,阅读与静态链接相关的部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM