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. Qt6 Widgets Application not working, exit code -1073741511
Forum Updated to NodeBB v4.3 + New Features

Qt6 Widgets Application not working, exit code -1073741511

Scheduled Pinned Locked Moved Unsolved General and Desktop
35 Posts 6 Posters 1.1k Views 3 Watching
  • 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.
  • H HQ2000

    @Christian-Ehrlicher
    Here are the DLLs:

    • C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Core.dll
    • C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Widgets.dll
    • C:\Qt\6.9.0\mingw_64\bin\libgcc_s_seh-1.dll
    • C:\Qt\6.9.0\mingw_64\bin\libstdc++-6.dll
    • C:\WINDOWS\system32\kernel32.dll
    • C:\WINDOWS\system32\MSVCRT.dll

    I looked up every single one and they're all available.

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #14

    @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

    C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Core.dll
    C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Widgets.dll

    Your CMakeLists.txt lists:

    find_package(Qt6 COMPONENTS
            Core
            Gui
            Widgets
            REQUIRED)
    

    So is there not at least a Qt6Gui.dll also required?

    I don't know any more than: somewhere you are messed up in what you have built, where you have placed it and what is required. And I do not use Windows or MinGW.

    Christian EhrlicherC 1 Reply Last reply
    0
    • JonBJ JonB

      @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

      C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Core.dll
      C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Widgets.dll

      Your CMakeLists.txt lists:

      find_package(Qt6 COMPONENTS
              Core
              Gui
              Widgets
              REQUIRED)
      

      So is there not at least a Qt6Gui.dll also required?

      I don't know any more than: somewhere you are messed up in what you have built, where you have placed it and what is required. And I do not use Windows or MinGW.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #15

      @JonB said in Qt6 Widgets Application not working, exit code -1073741511:

      C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Core.dll
      C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Widgets.dll

      Why are the dlls there? Where do they come from? Normally they are used from the PATH env var.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      JonBJ 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        @JonB said in Qt6 Widgets Application not working, exit code -1073741511:

        C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Core.dll
        C:\Users[MyUsrName]\CLionProjects\CPS\cmake-build-debug\Qt6Widgets.dll

        Why are the dlls there? Where do they come from? Normally they are used from the PATH env var.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #16

        @Christian-Ehrlicher I agree. I was just quoting from the OP's post. We know the OP really needs to sort out what they have where.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          HQ2000
          wrote on last edited by
          #17

          @JonB
          @Christian-Ehrlicher
          Since you both haven't worked with CLion and Qt so far (I guess), let me clarify some things:

          1. Qt6Gui is required as a standard (you can change that of course) if you use CLion with Qt, so it is available for but not required by the sample program since none of its functionality is used.
          2. The DLLs are there because because of the "find_package" command in the CMakeLists.txt file.

          I tried to run it with gdb as @Christian-Ehrlicher told me and I was able to run it with any problems...

          @hskoglund
          I tried it...same error

          Christian EhrlicherC 1 Reply Last reply
          0
          • H HQ2000

            @JonB
            @Christian-Ehrlicher
            Since you both haven't worked with CLion and Qt so far (I guess), let me clarify some things:

            1. Qt6Gui is required as a standard (you can change that of course) if you use CLion with Qt, so it is available for but not required by the sample program since none of its functionality is used.
            2. The DLLs are there because because of the "find_package" command in the CMakeLists.txt file.

            I tried to run it with gdb as @Christian-Ehrlicher told me and I was able to run it with any problems...

            @hskoglund
            I tried it...same error

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #18

            @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

            The DLLs are there because because of the "find_package" command in the CMakeLists.txt file.

            No, find_package() does not copy anything.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1
            • H HQ2000

              Hello everyone!

              I'm trying to get into programming with Qt6 on desktop using Qt Widgets and I have run into a problem: Whenever I build and run my code, I get the following output:

              Process finished with exit code -1073741511 (0xC0000139)
              

              Of course, mostly that's due to an incorrect setup up, but I have previously managed to successfully run the sample Qt program provided by the IDE. I checked the tutorial I used for the setup and it seems like it should work - but it doesn't.

              -- Additional Information --

              • Tutorial I used
              • OS: Windows 11 Home
              • IDE: CLion 2025.1
              • Build System: CMake (+ ninja)
              • Qt Installation: 6.9.0
              • Qt Directory: C:\Qt
              • Project Name: CPS
              • CMakeLists.txt file:
              cmake_minimum_required(VERSION 3.31)
              project(CPS)
              
              set(CMAKE_CXX_STANDARD 17)
              set(CMAKE_AUTOMOC ON)
              set(CMAKE_AUTORCC ON)
              set(CMAKE_AUTOUIC ON)
              
              set(CMAKE_PREFIX_PATH "C:/Qt/6.9.0/mingw_64")
              
              find_package(Qt6 COMPONENTS
                      Core
                      Gui
                      Widgets
                      REQUIRED)
              
              add_executable(CPS main.cpp)
              target_link_libraries(CPS
                      Qt::Core
                      Qt::Gui
                      Qt::Widgets
              )
              
              if (WIN32 AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
                  set(DEBUG_SUFFIX)
                  if (MSVC AND CMAKE_BUILD_TYPE MATCHES "Debug")
                      set(DEBUG_SUFFIX "d")
                  endif ()
                  set(QT_INSTALL_PATH "${CMAKE_PREFIX_PATH}")
                  if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
                      set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
                      if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
                          set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
                      endif ()
                  endif ()
                  if (EXISTS "${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll")
                      add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                              COMMAND ${CMAKE_COMMAND} -E make_directory
                              "$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
                      add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                              COMMAND ${CMAKE_COMMAND} -E copy
                              "${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll"
                              "$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
                  endif ()
                  foreach (QT_LIB Core Gui Widgets)
                      add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                              COMMAND ${CMAKE_COMMAND} -E copy
                              "${QT_INSTALL_PATH}/bin/Qt6${QT_LIB}${DEBUG_SUFFIX}.dll"
                              "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
                  endforeach (QT_LIB)
              endif ()
              

              Note: the CMake "code" at the end isn't directly relevant, it's standard since this isn't Qt creator.

              • main.cpp file:
              #include <QApplication>
              #include <QPushButton>
              
              int main(int argc, char *argv[]) {
                  QApplication a(argc, argv);
                  QPushButton button("Hello world!", nullptr);
                  button.resize(200, 100);
                  button.show();
                  return QApplication::exec();
              }
              

              Note: this the unchanged example project which is working under correct circumtances.

              Potential Errors
              • Path variable: I added "C:\Qt\Tools\mingw64\bin" and "C:\Qt\6.9.0\mingw_64\bin" to the System Path variable
              • CMake Prefix Path: Set correctly, see Qt path and CMakeLists.txt file

              If there's a piece of information I missed, tell me and I will add it.

              Thanks in advance
              HQ2000

              H Offline
              H Offline
              HQ2000
              wrote on last edited by HQ2000
              #19

              @Christian-Ehrlicher you're right, it's done here
              @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

               foreach (QT_LIB Core Gui Widgets)
                       add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                               COMMAND ${CMAKE_COMMAND} -E copy
                               "${QT_INSTALL_PATH}/bin/Qt6${QT_LIB}${DEBUG_SUFFIX}.dll"
                               "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
                endforeach (QT_LIB)
              
              JonBJ 1 Reply Last reply
              0
              • H HQ2000

                @Christian-Ehrlicher you're right, it's done here
                @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

                 foreach (QT_LIB Core Gui Widgets)
                         add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                                 COMMAND ${CMAKE_COMMAND} -E copy
                                 "${QT_INSTALL_PATH}/bin/Qt6${QT_LIB}${DEBUG_SUFFIX}.dll"
                                 "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
                  endforeach (QT_LIB)
                
                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #20

                @HQ2000
                So purely OOI could you comment on why that foreach has not copied Qt6Gui.dll as I asked earlier? However you say you know it works without that, somehow.

                Confirm you are not building your project for debug?

                Remove everything on your PATH environment variable so we know it is not picking something up somewhere?

                Christian EhrlicherC 1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #21

                  Don't do this. Adjust your PATH env var accordingly and use windeployqt when you want to deploy your app. Your are missing dll and plugins

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  1
                  • JonBJ JonB

                    @HQ2000
                    So purely OOI could you comment on why that foreach has not copied Qt6Gui.dll as I asked earlier? However you say you know it works without that, somehow.

                    Confirm you are not building your project for debug?

                    Remove everything on your PATH environment variable so we know it is not picking something up somewhere?

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by Christian Ehrlicher
                    #22

                    @JonB copying dlls around manually is wrong. The PATH env var has to be adjusted.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    JonBJ 1 Reply Last reply
                    1
                    • Christian EhrlicherC Christian Ehrlicher

                      @JonB copying dlls around manually is wrong. The PATH env var has to be adjusted.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #23

                      @Christian-Ehrlicher
                      ? Of course, I know! I was just trying to diagnose where the OP's problem might lie, given what is in the makefile. I posted before your post.

                      Christian EhrlicherC 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @Christian-Ehrlicher
                        ? Of course, I know! I was just trying to diagnose where the OP's problem might lie, given what is in the makefile. I posted before your post.

                        Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #24

                        @JonB said in Qt6 Widgets Application not working, exit code -1073741511:

                        where the OP's problem might lie,

                        The problem is, that he is copying only half of the required stuff because he is doing some strang stuff manually for no reason.

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        H 1 Reply Last reply
                        1
                        • Christian EhrlicherC Christian Ehrlicher

                          @JonB said in Qt6 Widgets Application not working, exit code -1073741511:

                          where the OP's problem might lie,

                          The problem is, that he is copying only half of the required stuff because he is doing some strang stuff manually for no reason.

                          H Offline
                          H Offline
                          HQ2000
                          wrote on last edited by HQ2000
                          #25

                          @Christian-Ehrlicher so, what else should I get you? Also, the whole CMakeLists.txt file is standard in CLion. I did not write this.
                          Yes, I did some things manually on purpose. Private data..

                          1 Reply Last reply
                          0
                          • Christian EhrlicherC Offline
                            Christian EhrlicherC Offline
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #26

                            As I already wrote - don't copy stuff around as it's wrong as it's missing things. Adjust your PATH var accordingly so that the Qt libs are properly found.

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            H 1 Reply Last reply
                            0
                            • Christian EhrlicherC Christian Ehrlicher

                              As I already wrote - don't copy stuff around as it's wrong as it's missing things. Adjust your PATH var accordingly so that the Qt libs are properly found.

                              H Offline
                              H Offline
                              HQ2000
                              wrote on last edited by
                              #27

                              @Christian-Ehrlicher
                              You mean I should just add their absolute paths to the PATH var?

                              Christian EhrlicherC 1 Reply Last reply
                              0
                              • H HQ2000

                                @Christian-Ehrlicher
                                You mean I should just add their absolute paths to the PATH var?

                                Christian EhrlicherC Offline
                                Christian EhrlicherC Offline
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #28

                                @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

                                You mean I should just add their absolute paths to the PATH var?

                                Again: add the path to the Qt dlls to the PATH env var.

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                H 1 Reply Last reply
                                0
                                • Christian EhrlicherC Christian Ehrlicher

                                  @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

                                  You mean I should just add their absolute paths to the PATH var?

                                  Again: add the path to the Qt dlls to the PATH env var.

                                  H Offline
                                  H Offline
                                  HQ2000
                                  wrote on last edited by HQ2000
                                  #29

                                  @Christian-Ehrlicher
                                  Did it, nothing changed. (I restarted the project, of course)
                                  Same with deleting the associated environment vars

                                  @JonB
                                  It did. But it is not needed, I viewed it in the Dependency Walker

                                  Christian EhrlicherC 1 Reply Last reply
                                  0
                                  • H HQ2000

                                    @Christian-Ehrlicher
                                    Did it, nothing changed. (I restarted the project, of course)
                                    Same with deleting the associated environment vars

                                    @JonB
                                    It did. But it is not needed, I viewed it in the Dependency Walker

                                    Christian EhrlicherC Offline
                                    Christian EhrlicherC Offline
                                    Christian Ehrlicher
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #30

                                    @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

                                    Same with deleting the associated environment vars

                                    Then you would get an error about missing dlls. You have some wrong dlls around somewhere.
                                    Delete all dlls you copied around, don't copy dlls around in your CMakeLists.txt or anywhere else during your build, use a clean build dir, set the env var accordingly and start it from the command line where you also started the dependency tools from...

                                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                    Visit the Qt Academy at https://academy.qt.io/catalog

                                    H 1 Reply Last reply
                                    1
                                    • Christian EhrlicherC Christian Ehrlicher

                                      @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

                                      Same with deleting the associated environment vars

                                      Then you would get an error about missing dlls. You have some wrong dlls around somewhere.
                                      Delete all dlls you copied around, don't copy dlls around in your CMakeLists.txt or anywhere else during your build, use a clean build dir, set the env var accordingly and start it from the command line where you also started the dependency tools from...

                                      H Offline
                                      H Offline
                                      HQ2000
                                      wrote on last edited by HQ2000
                                      #31

                                      @Christian-Ehrlicher
                                      I did not copy around any DLLs, this is a clean build dir (CLion pre-config)
                                      I will try it.

                                      Added the env vars:
                                      Screenshot 2025-05-02 183208.png

                                      Still get the Error messages that exactly these ones are missing...

                                      JonBJ Christian EhrlicherC 2 Replies Last reply
                                      0
                                      • H HQ2000

                                        @Christian-Ehrlicher
                                        I did not copy around any DLLs, this is a clean build dir (CLion pre-config)
                                        I will try it.

                                        Added the env vars:
                                        Screenshot 2025-05-02 183208.png

                                        Still get the Error messages that exactly these ones are missing...

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by JonB
                                        #32

                                        @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

                                        Added the env vars:

                                        You write that followed by a list of DLLs. What do you mean you did to what environment variable? Also you no longer list the Qt DLLs?

                                        Still get the Error messages that exactly these ones are missing...

                                        If you mean the 4 in that list are reported missing then you have not set your PATH correctly.

                                        I am lost.

                                        1 Reply Last reply
                                        0
                                        • H HQ2000

                                          @Christian-Ehrlicher
                                          I did not copy around any DLLs, this is a clean build dir (CLion pre-config)
                                          I will try it.

                                          Added the env vars:
                                          Screenshot 2025-05-02 183208.png

                                          Still get the Error messages that exactly these ones are missing...

                                          Christian EhrlicherC Offline
                                          Christian EhrlicherC Offline
                                          Christian Ehrlicher
                                          Lifetime Qt Champion
                                          wrote on last edited by Christian Ehrlicher
                                          #33

                                          @HQ2000 said in Qt6 Widgets Application not working, exit code -1073741511:

                                          Added the env vars:

                                          Why do you add some dlls? Please do what we tell you... otherwise we can't (and won't) help anymore.
                                          What's so hard to understand? Add the path to your Qt dlls to your PATH environment variable...

                                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                          Visit the Qt Academy at https://academy.qt.io/catalog

                                          H 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