我必须包括所有这些Qt DLL与我的应用程序吗? [英] Do I have to include all these Qt dlls with my application?

查看:184
本文介绍了我必须包括所有这些Qt DLL与我的应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



作为一个测试我创建了一个简单的应用程序使用 Visual Studio 2012 和Qt-VS-Add-in基于最新的 Qt5.1



为我工作(给出错误),我在互联网上搜索,发现很多人说,我必须复制下面提到的dll下面的目录:

  C:\Qt\Qt5.1.0\5.1.0\msvc2012\bin\ 

DLL必须复制才能使我的应用程序工作:

  icudt51.dll 
icuin51.dll
icuuc51.dll
libEGL.dll
libGLESv2.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Widgets.dll

我的问题是这些dll的大小,他们大约是37 MB,我的应用程序本身只有30 KB!所以,这些Qt库将添加至少37 MB到我的应用程序[我不认为它发生与其他基于Qt的应用程序我下载]。有没有任何解决方案可以让我最终得到一个小的.exe文件?!






我必须为Microsoft C ++编译器添加一个dll,你能为我解释一下吗?

解决方案

更新:使用 windeployqt.exe !效果非常好。



http://doc.qt.io/qt-5/windows-deployment.html#the-windows-deployment-tool


使用windeployqt的最简单的方法是将
的bin目录添加到PATH变量中,然后
运行:

  windeployqt< path-to-app-binary> 


更新:进一步测试后, windeployqt 没有复制所有的MingW DLL为我。 (在Windows 10上使用MingW 4.9.1测试Qt 5.4)。因此,您需要在部署之前手动获取最后3个dll:

  libgcc_s_dw2-1.dll 
libstdc ++ - 6。 dll
libwinpthread-1.dll

  C:\Qt\5.4\mingw491_32\bin 






我想你可能在你的列表中有一些额外的东西...我会仔细检查下面的链接中的文档...



这是关于它的最终文档:



http://doc.qt.io/qt-5/windows-deployment.html



http://doc.qt.io/qt-5/windows-deployment.html#application-dependencies



Qt DLL的大小



惊人的Qt库可以做很多,种大。



对于Qt 4.8 msvc QtCore4.dll 是2.5 MB和 QtGui4.dll 是8.4 MB。



Windows如何解决共享库/动态链接库



以下是Windows在运行时跟踪库的方法:



http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586( v = vs.85).aspx



单一小型EXE



那么你的EXE应该抓住它需要的库,并建立一个独立的exe。它仍然可能依赖于msvc可再发行组件。有关更多信息,请参阅下一节。但它现在编译你引用到你的EXE的 .lib ,你的exe不再指向其他动态链接库。它需要更多的时间来获得你的静态链接的exe环境设置。



你的exe将会变得更大,因为它现在包括你之前引用的库的二进制信息。



https://www.google.com / search?q = qt + static + linking



编辑:
静态构建exe, LGPL版本。
意味着如果您使用LGPL,您必须让您的目标文件容易访问最终用户。



@peppe描述的很好(见下面的注释):


技术上来说,允许你在LGPL下使用Qt时静态链接,应用程序未使用LGPL。唯一棘手的要求是保持第三方重新链接您的应用程序与不同的Qt版本的能力。但你可以很容易地遵守,f.i。通过提供一个庞大的应用程序对象文件(.o),只需要链接到任何Qt版本。


http://blog.qt.io/blog/2009/11 / 30 / qt-making-the-right-licensing-decision /



查看底部附近的图表。



MSVC Redistributables



如果您正在使用商业版本,那么您可以静态链接,而不必担心对象文件。

可再分发依赖关系与运行时库链接器选项有关。



http://msdn.microsoft.com/en-us/library/aa278396(v=vs.60).aspx



/ MD,/ ML,/ MT,/ LD (使用运行时库)


要在开发环境中找到这些选项,请单击项目菜单上的设置。然后单击C / C ++选项卡,并在类别框中单击代码生成。请参阅使用运行时库下拉框。


下面这两个链接谈论一些旧版本的visual studio,推理应该仍然成立。



http:// www。 davidlenihan.com/2008/01/choosing_the_correct_cc_runtim.html



如何使用Visual Studio Express 2005创建完全静态链接的.exe?



希望有帮助。


I'm totally new in using Qt and I don't know a lot of stuff.

As a test I created a simple application using Visual Studio 2012 and Qt-VS-Add-in based on the newest Qt5.1

After I compiled the application it didn't work for me ( gave errors ), I searched all over the internet and found a lot of people saying that I have to copy those dlls mentioned below form the directory :

C:\Qt\Qt5.1.0\5.1.0\msvc2012\bin\

DLL's I had to copy to make my application work:

icudt51.dll
icuin51.dll
icuuc51.dll
libEGL.dll
libGLESv2.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Widgets.dll

My problem is the size of these dlls, they're about "37 MB" and my application itself is only "30 KB" ! So, those Qt libraries will add at least 37 MB to my application [ Which I don't see it happens with other Qt-based applications I download ]. Is there any solution can make me end up with a single small .exe file ?!


And I heard some people saying that I have to also include a dll for Microsoft C++ Compiler, can you explain this for me ?

解决方案

UPDATE: Use windeployqt.exe! It works really well.

http://doc.qt.io/qt-5/windows-deployment.html#the-windows-deployment-tool

The simplest way to use windeployqt is to add the bin directory of your Qt installation (e.g. ) to the PATH variable and then run:

windeployqt <path-to-app-binary>

UPDATE: Upon Further testing, windeployqt did not copy over all the MingW dlls for me. (Tested with Qt 5.4 on Windows 10 with MingW 4.9.1). So you need to manually get the last 3 dlls before deploying:

libgcc_s_dw2-1.dll
libstdc++-6.dll
libwinpthread-1.dll

From

C:\Qt\5.4\mingw491_32\bin


I think you may have a few extras in your list... I would double check the docs in the links below...

Here is the definitive documentation on it:

http://doc.qt.io/qt-5/windows-deployment.html

http://doc.qt.io/qt-5/windows-deployment.html#application-dependencies

Size of Qt DLLs

The amazing Qt Libraries can do a lot, but they are kind of big. Some of the older versions of Qt might be a little smaller.

For Qt 4.8 msvc QtCore4.dll is 2.5 MB, and QtGui4.dll is 8.4 MB.

How Windows Resolves Shared Libraries/Dynamic Link Libraries (DLL)

Here is how Windows tracks down a library at runtime:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx

Single Small EXE

If you statically link, then your EXE should grab the libraries it needs and gets built into a stand alone exe. It still may be dependent on msvc redistributables. See the next section for more info on it. But it now compiles down the .libs that you reference into your EXE and your exe no longer is pointing at other dynamically linked libraries. It does take more time to get your statically linked exe environment setup.

Your exe will certainly get bigger as it now includes the binary information for the libraries that you referenced before.

https://www.google.com/search?q=qt+static+linking

EDIT: Statically building the exe, means that you aren't using the LGPL version. means that you have to have your object files easy to access to end users if you are using LGPL.

I think @peppe described it well (see comment below):

Technically, you are allowed to statically link when using Qt under LGPL, even if your application is not using LGPL. The only tricky requirement is keeping the ability for a third party to relink your application against a different Qt version. But you can comply with that easily, f.i. by providing a huge object file (.o) of your application, that only needs to be linked against any Qt version.

http://blog.qt.io/blog/2009/11/30/qt-making-the-right-licensing-decision/

Look at the chart near the bottom. If you are doing the commercial version, then you can statically link, without worrying about the object files.

MSVC Redistributables

Redistributable dependencies have to do with the run-time library linker options.

http://msdn.microsoft.com/en-us/library/aa278396(v=vs.60).aspx

/MD, /ML, /MT, /LD (Use Run-Time Library)

To find these options in the development environment, click Settings on the Project menu. Then click the C/C++ tab, and click Code Generation in the Category box. See the Use Run-Time Library drop-down box.

These two links below talk about some older versions of visual studio, but the reasoning should still stand.

http://www.davidlenihan.com/2008/01/choosing_the_correct_cc_runtim.html

How do I make a fully statically linked .exe with Visual Studio Express 2005?

Hope that helps.

这篇关于我必须包括所有这些Qt DLL与我的应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆