在Windows上部署Qt5应用程序的问题 [英] Problems with deploying Qt5 application on windows

查看:183
本文介绍了在Windows上部署Qt5应用程序的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有安装了Qt插件的Visual Studio 2013(社区版本),Qt5库(32位),我正在尝试创建独立于所有开发配置的可执行文件(它可能使用静态或共享库,我在这一点上不太在意)。



操作系统:Windows 7,x64。



我将解决方案配置 visual studio选项从 Debug 更改为发布,并将所有必需的库添加到配置属性 - >链接器 - >输入 - >额外的依赖关系。应用程序现在只有从可视化IDE运行时才启动,如果我尝试从生成的 .exe。中启动它,我得到应用程序无法开始正确(0xc000007b)错误。



我搜索并发现此错误代码表示以下问题之一:




  • 32位应用程序尝试加载64位DLL(不是我的情况我认为,Qt DLL是32位(我已经使用这个.exe: code> qt-opensource-windows-x86-msvc2013-5.5.0 。),我使用一些其他也是32位的.DLL)。

  • 有一些缺少的DLL。 (我将所有必需的Qt DLL与最终的可执行文件复制在同一个文件夹中)。



为了检查我的应用程序所需的依赖项,我使用 Dependency Walker 应用程序打开了 .exe 文件,这是它显示的:





在这个列表中也是 Qt5Multimedia.dll Qt5SerialPort.dll ,我通过在同一个文件夹中复制 .DLLs 来摆脱错误 .exe



任何想法如何解决?

解决方案

不要手动执行该操作,除非标准过程完全失败。已经有Qt Windows部署的标准工具 windeployqt



它关心Qt DLL依赖关系,复制一份 platforms\qwindows.dll ,并且它会使您无法使用 Dependency Walker 检测到的库的副本,因为图像插件和其他一些在运行时加载。



您甚至不需要在您的环境中使用您的Qt bin 文件夹 PATH 。最简单的部署:




  • 将内置 exe 二进制文件复制到新文件夹

  • 打开 cmd 该文件夹中的控制台

  • 调用 windeployqt 使用其完整路径(如果它不在系统中 PATH )并提供您的可执行文件,例如:


      c:\Qt\Qt5.5.1-vs2013-x64\5.5\msvc2013_64\bin\windeployqt.exe application.exe 





在该文件夹中所有需要的Qt DLL。当然,您也可以与MSVC可重新分发的问题,但是这些应该单独部署,并且每个系统安装一次。



工具 windeployqt 有各种选择。它也可以注意部署 qml 相关文件。



只有一些第三方库应手动复制if它们被使用,例如OpenSSL。


So I have Visual Studio 2013 (community edition) with Qt addin installed, Qt5 libraries (32bit), and I'm trying to create an executable that is independent of all development configurations (it may use static or shared libs, I don't really care at this point).

OS: Windows 7, x64.

For doing this I changed the Solution Confguration visual studio option from Debug to Release, and add all the necessary libs in Configuration Properties -> Linker -> Input -> Additional Dependencies. The application now starts only if I run it from visual IDE, If I try to start it from the generated .exe I got The application was unable to start correctly (0xc000007b) error.

I have searched and found that this error code indicates one of the following problems:

  • 32-bit app tries to load a 64-bit DLL (not my case I think, Qt DLLs are 32bit (I have installed using this .exe: qt-opensource-windows-x86-msvc2013-5.5.0.), and I use some other .DLLs which are also 32bit).
  • There are some missing DLLs. (I did copy all the necessary Qt DLLs in the same folder with the final executable).

For checking what dependencies my app requires, I opened the .exe file with Dependency Walker application, this is what it shows me:

in this list were also Qt5Multimedia.dll and Qt5SerialPort.dll, I get rid of the errors by copying the .DLLs in the same folder with the .exe.

Any ideas how to solve this?

解决方案

You should never do that operation manually unless the standard procedure completely fails. There is already standard tool for Qt Windows deploymend windeployqt.

It takes care about Qt DLL dependencies, makes a copy of platforms\qwindows.dll and also it makes a copy of libraries that you cannot detect with the Dependency Walker, since image plugins and some other are loaded at runtime.

You do not even need to have your Qt bin folder in your environment PATH. The simplest deployment:

  • copy built exe binary to a new folder
  • open cmd console in that folder
  • call windeployqt using its full path (if it is not in the system PATH) and provide your executable, for example:

    c:\Qt\Qt5.5.1-vs2013-x64\5.5\msvc2013_64\bin\windeployqt.exe application.exe
    

As a result you have in that folder all needed Qt DLLs. Of course you can have also issues with MSVC redistributables, but those should be deployed separately and installed once per system.

The tool windeployqt has various options. It can also take care about deployment of qml related files.

Only some 3rd party libraries should be copied manually if they are used, for example OpenSSL.

这篇关于在Windows上部署Qt5应用程序的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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