Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Visual Studio 2019/Qt C++ Executable file not working ?

Visual Studio 2019/Qt C++ Executable file not working ?

Scheduled Pinned Locked Moved Solved General and Desktop
c++visual studioqwidgetqt 5.4
11 Posts 3 Posters 7.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    learnist
    wrote on last edited by learnist
    #1

    i was working on a Qt C++ based project and now i want to run the UI Application from an executable file like 'project_name.exe', so in the Visual Studio menu, i clicked Build->Build project_name, i notice that a project_name.exe Application file is generated in

    Project_name > x64 > Release Folder,

    but when i click it, i am not able to open it ,it gives me a 3 System Errors boxes saying
    "The code execution cannot proceed because Qt5Widgets.dll" was not found. Reinstalling the program may fix this problem."
    "The code execution cannot proceed because Qt5Core.dll" was not found. Reinstalling the program may fix this problem."
    "The code execution cannot proceed because Qt5Gui.dll" was not found. Reinstalling the program may fix this problem."

    Any way i can solve this ?

    1 Reply Last reply
    0
    • L learnist

      @mrjj I have solved this by placing qt.conf file in my application's .exe folder

      [Paths]
      Prefix=C:\Qt\5.14.1\msvc2017_64
      Defining Prefix in your qt.conf file allows it to find the qwindows.dll platform plugin when your app starts.

      if i have a .conf file , i know that application will work perfectly fine on my computer , but not on my friend's computer in which there is no QT installed,

      so what i have done is i opened 'Developer command Prompt for Visual Studio 2019' and did this C:\Windows\System32>set PATH=C:/Qt/5.14.1/msvc2017_64/bin;%PATH%
      and then

      windeployqt C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe

      but still my application.exe was not working, so i noticed that all .dll files were of debug, all of them ended with ...d.dll , for example QWidgetsd.dll, so i deleted them and copied the correct .dll files

      i copied correct .dll files(which dont end with 'd') from C:\Qt\5.14.1\msvc2017_64 folder , now my application.exe works,but, there are still some dlls , which i can find in C:\Qt\5.14.1\msvc2017_64 folder , but these are like msvcp140_1d.dll, vcruntime140d.dll , i dunno where can i find them , coz these are not QT specific. these are visual studio related.

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #10

      @learnist said in Visual Studio 2019/Qt C++ Executable file not working ?:

      so i noticed that all .dll files were of debug, all of them ended with ...d.dll

      You may want to check windeployqt documentation, especially regarding --release switch

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      L 1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi
        You need a deployment folder to run the .exe alone
        a deployment folder is a folder with the needed Qt DLLS

        there is a tool you can use
        https://doc.qt.io/qt-5/windows-deployment.html
        it will copy the needed DLLS for you.

        Also explained here in good details
        http://www.tripleboot.org/?p=138

        L 1 Reply Last reply
        1
        • mrjjM mrjj

          Hi
          You need a deployment folder to run the .exe alone
          a deployment folder is a folder with the needed Qt DLLS

          there is a tool you can use
          https://doc.qt.io/qt-5/windows-deployment.html
          it will copy the needed DLLS for you.

          Also explained here in good details
          http://www.tripleboot.org/?p=138

          L Offline
          L Offline
          learnist
          wrote on last edited by
          #3

          @mrjj I am now in a state that when i click ```
          project_name.exe

          nothing happens, Here are the steps i took , i opened Developer Command Prompt for VS 2019, typed this ```
          C:\Qt\5.14.1\msvc2017_64\bin>set PATH C:\Qt\5.14.1\msvc2017_64\bin
          

          and then this

          C:\Qt\5.14.1\msvc2017_64\bin>windeployqt.exe C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe
          

          Then the errors about QtWidgets.dll, QtGui.dll missing were gone, but i was facing some other errors like libGLESv2.dll is missing, so i copied it from visual studio folder and pasted it, further i got some other errors like MSVCP140_APP.dll and also VCRUNTIME140_APP.dll is missing , so i downloaded it from the internet and pasted that dll file in my project_name.exe folder,

          now when i click it , i get no errors , but when i click projectname.exe file, nothing happens,

          Why is deploying in QT so tough ?

          mrjjM 1 Reply Last reply
          0
          • L learnist

            @mrjj I am now in a state that when i click ```
            project_name.exe

            nothing happens, Here are the steps i took , i opened Developer Command Prompt for VS 2019, typed this ```
            C:\Qt\5.14.1\msvc2017_64\bin>set PATH C:\Qt\5.14.1\msvc2017_64\bin
            

            and then this

            C:\Qt\5.14.1\msvc2017_64\bin>windeployqt.exe C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe
            

            Then the errors about QtWidgets.dll, QtGui.dll missing were gone, but i was facing some other errors like libGLESv2.dll is missing, so i copied it from visual studio folder and pasted it, further i got some other errors like MSVCP140_APP.dll and also VCRUNTIME140_APP.dll is missing , so i downloaded it from the internet and pasted that dll file in my project_name.exe folder,

            now when i click it , i get no errors , but when i click projectname.exe file, nothing happens,

            Why is deploying in QT so tough ?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #4

            @learnist
            Hi

            • Why is deploying in QT so tough ?
              its only tough the first few times :)

            windeployqt.exe has option called --compiler-runtime
            that tells it to also copy MSVCP140_APP.dll and VCRUNTIME140_APP.

            Just to be sure. you go into the folder and click the .exe, correct ?

            To test on same machine where Qt is installed, i often rename the c:\Qt folder
            so it cant possibly find anything there.
            (i check the .exe and then rename back)

            L 1 Reply Last reply
            0
            • mrjjM mrjj

              @learnist
              Hi

              • Why is deploying in QT so tough ?
                its only tough the first few times :)

              windeployqt.exe has option called --compiler-runtime
              that tells it to also copy MSVCP140_APP.dll and VCRUNTIME140_APP.

              Just to be sure. you go into the folder and click the .exe, correct ?

              To test on same machine where Qt is installed, i often rename the c:\Qt folder
              so it cant possibly find anything there.
              (i check the .exe and then rename back)

              L Offline
              L Offline
              learnist
              wrote on last edited by
              #5

              @mrjj Yes, When i click

              project_name.exe
              

              the cursor changes to loading icon and then nothing happens, im not really sure where i went wrong. , is there a way to undo all of this and do it correctly.

              mrjjM 1 Reply Last reply
              0
              • L learnist

                @mrjj Yes, When i click

                project_name.exe
                

                the cursor changes to loading icon and then nothing happens, im not really sure where i went wrong. , is there a way to undo all of this and do it correctly.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @learnist
                Hi
                its just a build folder so you can just delete it and rebuild to get your exe back.
                Or simply press ctrl+a and
                then hold ctrl and click the exe to deselect it,
                then press delete button to delete anything else.

                Then open command prompt again and
                do
                C:\Qt\5.14.1\msvc2017_64\bin>windeployqt.exe --compiler-runtime
                C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe

                do you use openGL since it wants libGLESv2 ?
                Do you use QML also ?

                L 1 Reply Last reply
                0
                • mrjjM mrjj

                  @learnist
                  Hi
                  its just a build folder so you can just delete it and rebuild to get your exe back.
                  Or simply press ctrl+a and
                  then hold ctrl and click the exe to deselect it,
                  then press delete button to delete anything else.

                  Then open command prompt again and
                  do
                  C:\Qt\5.14.1\msvc2017_64\bin>windeployqt.exe --compiler-runtime
                  C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe

                  do you use openGL since it wants libGLESv2 ?
                  Do you use QML also ?

                  L Offline
                  L Offline
                  learnist
                  wrote on last edited by
                  #7

                  @mrjj Hello mrjj, i deleted the release and build it again, so i got a fresh start here, Nope, i did not use OpenGL and QML,

                  i used Visual Studio 2019 when i was workin on this project. so instead of command prompt should i use "Developer command prompt for VS 2019" ??

                  mrjjM 1 Reply Last reply
                  0
                  • L learnist

                    @mrjj Hello mrjj, i deleted the release and build it again, so i got a fresh start here, Nope, i did not use OpenGL and QML,

                    i used Visual Studio 2019 when i was workin on this project. so instead of command prompt should i use "Developer command prompt for VS 2019" ??

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #8

                    @learnist said in Visual Studio 2019/Qt C++ Executable file not working ?:

                    i used Visual Studio 2019 when i was workin on this project. so instead of command prompt should i use "Developer command prompt for VS 2019" ??

                    It this case it should not be important but should not hurt either.
                    I was wrong . its best to do.
                    if you have multiple Qt installed then
                    its important from which folder you start the actual windeployqt.exe - from

                    L 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @learnist said in Visual Studio 2019/Qt C++ Executable file not working ?:

                      i used Visual Studio 2019 when i was workin on this project. so instead of command prompt should i use "Developer command prompt for VS 2019" ??

                      It this case it should not be important but should not hurt either.
                      I was wrong . its best to do.
                      if you have multiple Qt installed then
                      its important from which folder you start the actual windeployqt.exe - from

                      L Offline
                      L Offline
                      learnist
                      wrote on last edited by learnist
                      #9

                      @mrjj I have solved this by placing qt.conf file in my application's .exe folder

                      [Paths]
                      Prefix=C:\Qt\5.14.1\msvc2017_64
                      Defining Prefix in your qt.conf file allows it to find the qwindows.dll platform plugin when your app starts.

                      if i have a .conf file , i know that application will work perfectly fine on my computer , but not on my friend's computer in which there is no QT installed,

                      so what i have done is i opened 'Developer command Prompt for Visual Studio 2019' and did this C:\Windows\System32>set PATH=C:/Qt/5.14.1/msvc2017_64/bin;%PATH%
                      and then

                      windeployqt C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe

                      but still my application.exe was not working, so i noticed that all .dll files were of debug, all of them ended with ...d.dll , for example QWidgetsd.dll, so i deleted them and copied the correct .dll files

                      i copied correct .dll files(which dont end with 'd') from C:\Qt\5.14.1\msvc2017_64 folder , now my application.exe works,but, there are still some dlls , which i can find in C:\Qt\5.14.1\msvc2017_64 folder , but these are like msvcp140_1d.dll, vcruntime140d.dll , i dunno where can i find them , coz these are not QT specific. these are visual studio related.

                      Pablo J. RoginaP 1 Reply Last reply
                      1
                      • L learnist

                        @mrjj I have solved this by placing qt.conf file in my application's .exe folder

                        [Paths]
                        Prefix=C:\Qt\5.14.1\msvc2017_64
                        Defining Prefix in your qt.conf file allows it to find the qwindows.dll platform plugin when your app starts.

                        if i have a .conf file , i know that application will work perfectly fine on my computer , but not on my friend's computer in which there is no QT installed,

                        so what i have done is i opened 'Developer command Prompt for Visual Studio 2019' and did this C:\Windows\System32>set PATH=C:/Qt/5.14.1/msvc2017_64/bin;%PATH%
                        and then

                        windeployqt C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe

                        but still my application.exe was not working, so i noticed that all .dll files were of debug, all of them ended with ...d.dll , for example QWidgetsd.dll, so i deleted them and copied the correct .dll files

                        i copied correct .dll files(which dont end with 'd') from C:\Qt\5.14.1\msvc2017_64 folder , now my application.exe works,but, there are still some dlls , which i can find in C:\Qt\5.14.1\msvc2017_64 folder , but these are like msvcp140_1d.dll, vcruntime140d.dll , i dunno where can i find them , coz these are not QT specific. these are visual studio related.

                        Pablo J. RoginaP Offline
                        Pablo J. RoginaP Offline
                        Pablo J. Rogina
                        wrote on last edited by
                        #10

                        @learnist said in Visual Studio 2019/Qt C++ Executable file not working ?:

                        so i noticed that all .dll files were of debug, all of them ended with ...d.dll

                        You may want to check windeployqt documentation, especially regarding --release switch

                        Upvote the answer(s) that helped you solve the issue
                        Use "Topic Tools" button to mark your post as Solved
                        Add screenshots via postimage.org
                        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                        L 1 Reply Last reply
                        2
                        • Pablo J. RoginaP Pablo J. Rogina

                          @learnist said in Visual Studio 2019/Qt C++ Executable file not working ?:

                          so i noticed that all .dll files were of debug, all of them ended with ...d.dll

                          You may want to check windeployqt documentation, especially regarding --release switch

                          L Offline
                          L Offline
                          learnist
                          wrote on last edited by
                          #11

                          @Pablo-J-Rogina Thanks , This worked just perfect.

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved