无法在以发布模式编译的ide之外运行qt-creator可执行文件 [英] Unable to run qt-creator executable outside ide compiled in release mode

查看:282
本文介绍了无法在以发布模式编译的ide之外运行qt-creator可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

切换到发布模式以构建一个小项目后,当我尝试从qt-creator ide内部运行该项目时,一切正常。但是当我转到文件夹 build-< project_name> -Desktop_Qt_5_14_1_MinGW_64_bit- Release 并尝试运行此目录中生成的可执行文件时,出现此错误:





有人知道这里的问题吗?如果它是某些缺少的dll,我认为它将指定缺少的dll,对吗?还是我弄错了?



更新



运行后 windeployqt ,此命令为我的应用程序找到了依赖项,创建了一些文件夹,但现在尝试运行该应用程序时出现错误:





更新2



在运行实用的 dependency walker 之后,我遇到了以下错误:





我正在使用此构建套件在qt-creator中构建项目:



解决方案

以下是我对Qt部署&的全部了解; Windows上的问题。


  1. 检查项目的发布配置是否不包含任何库调试版本的链接

  2. 在发布模式下构建您的应用。如有疑问,请使用重建在IDE中查看编译输出窗口,它实际使用的路径。

  3. 使用 windeployqt 工具自动复制所有必需的Qt dll。到可执行文件的文件夹。确保从正确的文件夹中使用 windeployqt.exe 。例如,当前我有一个版本的Qt框架,但有两个版本的windeployqt:用于 x86 x64 编译器。如果您安装了多个版本的Qt,则可能有多个版本的工具。

  C:\Qt\Qt5.14.1\5.14.1\msvc2017\bin\windeployqt.exe 
C:\Qt\Qt5.14.1\5.14.1\msvc2017_64\bin\windeployqt.exe




  1. 将编译器库复制到发行文件夹。请确保您要从用于构建的完全编译器中复制库。


  2. 复制所有必需的其他第三方动态库。确保不是调试版本。


  3. 如果问题仍然存在,请在出现以下问题时按 Ctrl + C 。错误消息处于活动状态。它将复制消息框中的所有文本。将邮件的主要部分粘贴到Google。


  4. 如果问题仍然存在,请在某些dll依赖查看器中打开您的.exe文件。这就是我在


    1. 确保您的应用程序不会尝试向没有相应特权的系统保护文件夹,例如 c:\Program Files\


    2. 如果问题仍然存在,请尽可能简化您的项目。为一个空项目运行发布。除了逐步添加模块,功能和库。


    3. 如果一切正常,请在完全干净的虚拟机上测试应用程序。







    编辑。我用Google搜索您的错误文本以及哪些内容我发现:

    https://android.developreference.com/article/11361766/Qt5+deployment+%E2%80%9Cprocedure+entry+point+could+not+be+location% E2%80%9D


    问题是由于某些
    原因,windeployqt无法找到gcc。我使用SET
    PATH =%PATH%; C:\Qt\Tools\mingw530_32\bin将其添加到cmd的路径中。再次运行windeployqt
    之后,我不必手动复制libgcc_s_dw2-1.dll和
    libwinpthread-1.dll,它使用了正确的Qt5Core.dll,因为应用程序是现在工作正常。


    Edit2。多余的项目已删除。


    After switch to release mode to build a small project I have, when I try run it from inside the qt-creator ide, all goes fine. But when I go to the folder build-<project_name>-Desktop_Qt_5_14_1_MinGW_64_bit- Release and try run the executable generated in this directory, I got this error:

    Anyone knows what the problem here? If it was some missing dll, I supose it will specify what dll was missing, right? Or I am mistaken?

    update

    After run windeployqt, this command found dependencies for my application, create some folders, but now I am getting tis error when try to run it:

    update 2

    after run the utilitary dependency walker, i got this errors on it:

    I am using this build kit to build the project in qt-creator:

    解决方案

    Here is all I know about Qt deployment & issues on Windows.

    1. Check whether Release configuration of your project doesn't contain links to any debug versions of libraries.
    2. Build your app in Release mode. Use Rebuild, If in doubt. See compile output window in the IDE, what paths it actually uses.
    3. Use windeployqt tool to automatically copy all the necessary Qt dlls to the executable's folder. Be sure you are using windeployqt.exe from the correct folder. For example, currently I have one version of Qt framework, but two versions of windeployqt: for x86 and x64 compilers. In the case you have more than one version of Qt installed, you may have several versions of the tool.

    .

     C:\Qt\Qt5.14.1\5.14.1\msvc2017\bin\windeployqt.exe
     C:\Qt\Qt5.14.1\5.14.1\msvc2017_64\bin\windeployqt.exe
    

    1. Copy compiler libraries to the release folder. Make sure that you're copying libraries from the exact compiler you used to build.

    2. Copy all necessary additional 3-rd party dynamic libraries. Make sure it is not debug versions.

    3. If the problem persists, press Ctrl+C when the error message is active. It will copy all the text from the message box. Paste main part of the message to Google.

    4. If the problem persists, open your .exe file in some dll-dependency viewer. Here is how I can see this in Lister. Be note that such a tool will show you not only missing dlls, but also a full path for each dll that your executable actually use. More power tool is Dependency Walker.

    1. Make sure your application doesn't try to write something to a system protected folder, such as c:\Program Files\, without corresponding privileges.

    2. If the problem still persists, simplify your project as much as possible. Run Release for an empty project. Than add modules, functionality and libraries step-by-step.

    3. If everything is okay, test the application on a completely clean virtual machine.


    Edit. I google your error text and what I found:
    https://android.developreference.com/article/11361766/Qt5+deployment+%E2%80%9Cprocedure+entry+point+could+not+be+located%E2%80%9D

    The problem was that windeployqt was unable to locate gcc for some reason. I added it to my path from cmd with SET PATH=%PATH%;C:\Qt\Tools\mingw530_32\bin. After I ran windeployqt again, I did not have to copy libgcc_s_dw2-1.dll and libwinpthread-1.dll over manually and it used the correct Qt5Core.dll, since the application is now working fine.

    Edit2. Excess item removed.

    这篇关于无法在以发布模式编译的ide之外运行qt-creator可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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