Search code examples
qtdllqt-creatorrelease

Unable to run qt-creator executable outside ide compiled in release mode


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:

enter image description here

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:

enter image description here

update 2

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

enter image description here

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

enter image description here


Solution

  • 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.

    enter image description here

    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://stackoverflow.com/a/52127944/

    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.