Qt5应用程序无法运行 [英] Qt5 Application Does Not Run

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

问题描述

我使用Qt 5(与Visual Studio '12编译)创建了一个应用程序.它可以在我的机器上工作.

但是,当我尝试在另一台计算机上运行它时,它不起作用.我通过cmd收集的输出产生了一个空文件.

目录结构如下:

  • myapp.exe
  • icudt52.dll
  • icuin52.dll
  • icuuc52.dll
  • libEGL.dll
  • libGLESv2.dll
  • msvcp120.dll
  • msvcr120.dll
  • Qt5Core.dll
  • Qt5Gui.dll
  • platforms/qminimal.dll
  • platforms/qwindows.dll

我发现最相关的帖子是中找到MSVC Redistributable的最新安装程序./p>

希望有帮助.

I created an application using Qt 5 (compiled with Visual Studio '12). It works on my machine.

However, it doesn't work when I attempt to run it on another machine. The output I collected through cmd yielded an empty file.

The directory structure is as follows:

  • myapp.exe
  • icudt52.dll
  • icuin52.dll
  • icuuc52.dll
  • libEGL.dll
  • libGLESv2.dll
  • msvcp120.dll
  • msvcr120.dll
  • Qt5Core.dll
  • Qt5Gui.dll
  • platforms/qminimal.dll
  • platforms/qwindows.dll

The most relevant post I found was Application deployed with QT5 libraries does not start on Windows 7 - yet the solution (including qwindows.dll & qminimal.dll) didn't work.

Any ideas?

解决方案

Windows will report a number of launch errors just when you double click on your exe outside Qt Creator. It looks like you have included most or all of these already.

Your development machine typically will not have problems launching and running its qt plugins because of the LibraryPaths that are searched by your exe. http://qt-project.org/doc/qt-5/qcoreapplication.html#libraryPaths

Dependency Walker will do the job and show you what you need to know, but the output is pretty complex and can be hard to decipher.

The easiest way I have found to figure out what Qt plugin dlls I am using at runtime on Windows is to do the following:

  1. Exit Qt Creator.

  2. Open the install folder for the compiler you are using with Qt in Explorer. For example:

    C:/Qt/5.3/msvc2010_opengl/
    

  3. Create a copy of the plugins folder in place (Copy of plugins folder in the same path as plugins, so its parent is msvc2010_opengl in this case).

  1. In another explorer window, open your exe (Qt program) on your development machine. Run a minimal test of your program to make sure the major features are working. (Many runtime plugins don't get loaded until QObjects that use them are instantiated).

  2. Delete the plugins folder in the Qt path.

  3. Windows will lock up all the dlls that are in use by your exe and prevent you from deleting a number of dlls. Click skip for all the un-deletable folders and files.

  1. Now go into each of the folders that you couldn't delete before and try to delete all the individual dll's in each folder. Click skip for all the un-deletable dlls.

  2. Now when you are all done, you are left with a skeleton of a plugins folder, only showing dlls that your application is using.

  3. It will probably include the folders: accessibility, platforms and imageformats and more depending on what you included in your .pro file.

  4. Close your exe.

  5. Copy the contents of your stripped down plugins folder to sit right next to your exe.

  6. Restore your backup of the plugins folder (delete the stripped down plugins folder from your Qt path and restore the Copy of plugins).

  7. Now you should be good to go. Test on a non-development machine.

A Note on VS C++ Runtimes

Also on some machines when deploying Qt with MSVC, the msvcrXXX.dll doesn't match what the rest of the system is using. Instead of deploying msvcrXXX.dll, instead in our installers at our office, we include the Microsoft C++ Redistributable Installer and run it in the install script. And on a few machines they had corrupted Redistributables, and we had to do a force install of redistributables to fix the `Referral from server' error we would sometimes get.

You can find the latest installer for MSVC Redistributables here Latest Supported Visual C++ Downloads.

Hope that helps.

这篇关于Qt5应用程序无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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