Qt 5.0 程序在 QtCreator 中运行但不在外部 [英] Qt 5.0 program runs in QtCreator but not outside

查看:48
本文介绍了Qt 5.0 程序在 QtCreator 中运行但不在外部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是上下文:

  • 我在 Windows 7 x64 下用 Qt 开发了一个程序.
  • 我已升级到 Qt 5.0.1、QtCreator 2.6.1、编译器 VS2010.

现在的状态:

  • 我的程序在 QtCreator 中运行良好,但是,当我在外面尝试时,收到了几个错误.
  • 我检查了这个话题,这给了我一些答案:qtcreator - exe 在 qtcreator 内部运行良好,但在外部运行不正常
  • 因此,我添加了 Qt dll,它有所帮助,不再有 Missing Libraries 消息.
  • 不过,它不会在 QtCreator 之外运行(没有更多错误消息,我只是没有运行)所以我添加了 platforms 目录,其中包含 qminimal>qwindows dll,它没有帮助.
  • 我还按照建议下载并添加了 libEGL.dll,但没有结果.
  • My program runs fine in QtCreator but, when I tried it outside, I received several errors.
  • I checked this topic which gave me some answers: qtcreator - exe does work fine inside qtcreator but doesn't outside
  • I thus added Qt dlls and it helped, no more Missing Libraries messages.
  • Still, it would not run outside QtCreator (no more error message, I just doesn't run) so I added the platforms directory with both qminimal and qwindows dlls, it didn't help.
  • I also downloaded and added libEGL.dll as sugested, with no result.

我被困住了,真的可以提供一点帮助.

I'm stuck and could really a little help.

推荐答案

这是一个依赖问题,你的程序无法加载它的依赖,将依赖文件(DLL文件)复制到应用程序目录是一种临时方式,这是非常危险的您的应用程序在目标机器上可能遇到问题的方式,如果目标机器上没有安装正确版本的 Microsoft 运行时库,您的应用程序将无法正确运行,您可以通过 Dependency Walker.

This is a dependency problem that your program can not load its dependencies, copy dependency files (DLL files) to application directory is a temporary way, this is very risky way that your application may faced with problems in target machine, if target machine does not have correct version of Microsoft Runtime Library installed on them, your application can not run correctly, you can find which dependenices (DLL files) your application needs them with Dependency Walker.

有两种方法可以解决这个问题:

There are two ways to solve this:

第一个是使用 Microsoft Visual C++ 2010 Runtime installshield 中的组件(或其他版本取决于您用它编译的运行时库的版本),该用户可以静默安装它,或者在不使用 installshield 的情况下使用其可执行二进制文件安装,然后将 DLL 文件复制到应用程序目录并分发

First one is to use Microsoft Visual C++ 2010 Runtime components in your installshield (or another versions depends on which version of Runtime library you compiled with it), that user could install it silently, or install with its executable binary without use installshield, and later copy DLL files to application directory and distribute it.

其次是使用静态编译方法来避免此类问题,但是对于应用程序的静态编译,如果要将其分发到目标机器上,则需要商业许可证.

Second is use static compilation method to avoid such problems like that, but for static compile of your application you need a Commercial License if you want to distribute it on target machines.

在目标机器上部署您的应用程序:

For Deploy Your Application on target machines:

1) 放置 Microsoft Visual C++ 2010 运行时应用程序文件夹中的库,以便用户将其安装在他们的机器上.

1) Put Microsoft Visual C++ 2010 Runtime Library in your application folder, so user will install it on their machine.

2) 从应用程序文件夹中的 Qt's bin 文件夹复制应用程序所需的依赖项(DLL files)(bin 文件夹路径:C:\Qt\Qt5.0.2\5.0.2\msvc2010\bin).

2) Copy application required dependencies (DLL files) from Qt's bin folder in your application folder (bin folder path:C:\Qt\Qt5.0.2\5.0.2\msvc2010\bin).

3) 从您的应用程序文件夹中的 Qt's plugins 文件夹中复制 imageformats 文件夹(如果您在应用程序中使用任何图像资源文件).

3) Copy imageformats folder from your Qt's plugins folder in your application folder (if you use any image resource file in your application).

4) 从应用程序文件夹中的 Qt's plugins 文件夹中复制 platforms 文件夹.

4) Copy platforms folder from your Qt's plugins folder in your application folder.

Qt 的插件文件夹路径:C:\Qt\Qt5.0.2\5.0.2\msvc2010\plugins\

Qt's plugins folder path: C:\Qt\Qt5.0.2\5.0.2\msvc2010\plugins\

这篇关于Qt 5.0 程序在 QtCreator 中运行但不在外部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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