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

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

问题描述

所以我安装了 Qt 插件的 Visual Studio 2013(社区版)、Qt5 库(32 位),并且我正在尝试创建一个独立于所有开发配置的可执行文件(它可能使用静态或共享库,我暂时不在乎).

操作系统:Windows 7、x64.

为此,我将 Solution Configuration Visual Studio 选项从 Debug 更改为 Release,并在 中添加所有必要的库配置属性->链接器->输入->附加依赖项.该应用程序现在仅在我从可视化 IDE 运行时启动,如果我尝试从生成的 .exe 启动它,我得到 应用程序无法正确启动 (0xc000007b)错误.

我查了发现这个错误码表示以下问题之一:

  • 32 位应用程序尝试加载 64 位 DLL(我认为不是我的情况,Qt DLL 是 32 位的(我已使用此 .exe 安装:qt-opensource-windows-x86-msvc2013-5.5.0.),我使用其他一些也是 32 位的 .DLL).
  • 缺少一些 DLL.(我确实将所有必要的 Qt DLL 与最终可执行文件复制到同一文件夹中).

为了检查我的应用程序需要哪些依赖项,我使用 Dependency Walker 应用程序打开了 .exe 文件,这就是它向我展示的内容:

在这个列表中还有 Qt5Multimedia.dllQt5SerialPort.dll,我通过复制 .DLLs.exe 在同一文件夹中.

有什么办法解决这个问题吗?

解决方案

除非标准程序完全失败,否则永远不要手动执行该操作.已经有用于 Qt Windows deploymend windeployqt 的标准工具.

它处理 Qt DLL 依赖关系,制作 platformsqwindows.dll 的副本,还制作您无法使用 Dependency Walker 检测到的库的副本,因为图像插件和其他一些插件是在运行时加载的.

您甚至不需要将 Qt bin 文件夹放在您的环境 PATH 中.最简单的部署:

  • 将构建的 exe 二进制文件复制到新文件夹
  • 在该文件夹中打开 cmd 控制台
  • 使用其完整路径调用 windeployqt(如果它不在系统 PATH 中)并提供您的可执行文件,例如:<块引用>

    c:QtQt5.5.1-vs2013-x645.5msvc2013_64inwindeployqt.exe application.exe

因此,您在该文件夹中拥有所有需要的 Qt DLL.当然,您也可能会遇到 MSVC 可再发行组件的问题,但这些组件应单独部署并在每个系统中安装一次.

windeployqt 工具有多种选择.它还可以负责qml相关文件的部署.

如果使用了某些第 3 方库,则应手动复制它们,例如 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 platformsqwindows.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:QtQt5.5.1-vs2013-x645.5msvc2013_64inwindeployqt.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天全站免登陆