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 781 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.
  • A Axel Spoerl
    1 May 2025, 23:39

    Please post the full cmake and ninja output.

    H Offline
    H Offline
    HQ2000
    wrote on 2 May 2025, 08:28 last edited by HQ2000 5 Feb 2025, 08:38
    #4

    @Axel-Spoerl
    CMake output:

    "C:\Program Files\JetBrains\CLion 2024.3.1.1\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2024.3.1.1/bin/ninja/win/x64/ninja.exe" -G Ninja -S C:\Users\[MyUsrName]\CLionProjects\CPS -B C:\Users\[MyUsrName]\CLionProjects\CPS\cmake-build-debug
    -- The C compiler identification is GNU 11.2.0
    -- The CXX compiler identification is GNU 11.2.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: C:/Qt/Tools/mingw1120_64/bin/gcc.exe - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Qt/Tools/mingw1120_64/bin/c++.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
    -- Found Threads: TRUE
    -- Performing Test HAVE_STDATOMIC
    -- Performing Test HAVE_STDATOMIC - Success
    -- Found WrapAtomic: TRUE
    -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
    -- Configuring done (7.8s)
    -- Generating done (0.4s)
    -- Build files have been written to: C:/Users/[MyUsrName]/CLionProjects/CPS/cmake-build-debug
    
    [Previous CMake output restored: 01.05.2025 21:51]
    

    I know it has been restored from yesterday, but since I didn't change anything, it should be fine.

    Ninja output:

    ====================[ Build | CPS | Debug ]=====================================
    "C:\Program Files\JetBrains\CLion 2024.3.1.1\bin\cmake\win\x64\bin\cmake.exe" --build C:\Users\[MyUsrName]\CLionProjects\CPS\cmake-build-debug --target CPS -j 14
    [1/4] Automatic MOC and UIC for target CPS
    [2/3] Building CXX object CMakeFiles/CPS.dir/main.cpp.obj
    [3/3] Linking CXX executable CPS.exe
    
    Build finished
    

    I'm not 100% sure if that above is the ninja output, correct me if I'm wrong.

    Also, I replaced every apperance of my Username with "[MyUsrName]".

    @ChrisW67 You mean my installation of Qt is incomplete?
    Anyways here are the components I installed:
    Screenshot 2025-05-02 103506.png

    1 Reply Last reply
    0
    • C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 2 May 2025, 08:48 last edited by
      #5

      Check if all dependencies can be found via a dependency checker

      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 2 May 2025, 09:33
      0
      • C Christian Ehrlicher
        2 May 2025, 08:48

        Check if all dependencies can be found via a dependency checker

        H Offline
        H Offline
        HQ2000
        wrote on 2 May 2025, 09:33 last edited by
        #6

        @Christian-Ehrlicher I checked it and every dependency can be found

        1 Reply Last reply
        0
        • C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 2 May 2025, 09:49 last edited by
          #7

          Also make sure the correct one (from your Qt installation, not from QtCreator directory) are loaded.

          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 2 May 2025, 10:59
          0
          • C Christian Ehrlicher
            2 May 2025, 09:49

            Also make sure the correct one (from your Qt installation, not from QtCreator directory) are loaded.

            H Offline
            H Offline
            HQ2000
            wrote on 2 May 2025, 10:59 last edited by
            #8

            @Christian-Ehrlicher the correct one is used.

            C 1 Reply Last reply 2 May 2025, 11:20
            0
            • H HQ2000
              2 May 2025, 10:59

              @Christian-Ehrlicher the correct one is used.

              C Online
              C Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 2 May 2025, 11:20 last edited by
              #9

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

              the correct one is used.

              Then you would not get this crash. Start in a debugger and see what dlls are loaded and at which dll it is crashing.

              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 2 May 2025, 11:52
              0
              • C Christian Ehrlicher
                2 May 2025, 11:20

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

                the correct one is used.

                Then you would not get this crash. Start in a debugger and see what dlls are loaded and at which dll it is crashing.

                H Offline
                H Offline
                HQ2000
                wrote on 2 May 2025, 11:52 last edited by HQ2000 5 Feb 2025, 11:56
                #10

                @Christian-Ehrlicher do you have an example which one? With the standard CLion debug config I get the exit code -1
                here are the loaded DLLs:

                1 Reply Last reply
                0
                • C Online
                  C Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 2 May 2025, 11:53 last edited by
                  #11

                  I would either start gdb from the command line or in visual studio - esp. in Visual Studio the debugger panel shows what dlls are loaded when in a nice view. Never used CLion.

                  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
                  0
                  • H Offline
                    H Offline
                    HQ2000
                    wrote on 2 May 2025, 12:08 last edited by HQ2000 5 Feb 2025, 12:08
                    #12

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

                    J 1 Reply Last reply 2 May 2025, 12:18
                    0
                    • H Offline
                      H Offline
                      hskoglund
                      wrote on 2 May 2025, 12:09 last edited by
                      #13

                      Hi, another option to show what DLLs an .exe has loaded is to run ListDLLs start a CMD and type listdlls CPS

                      P.S. Sometimes a 3rd party antivirus can cause that error 0xC0000139, so if you have one running, try disabling it.

                      1 Reply Last reply
                      0
                      • H HQ2000
                        2 May 2025, 12:08

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

                        J Offline
                        J Offline
                        JonB
                        wrote on 2 May 2025, 12:18 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.

                        C 1 Reply Last reply 2 May 2025, 12:26
                        0
                        • J JonB
                          2 May 2025, 12:18

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

                          C Online
                          C Online
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on 2 May 2025, 12:26 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

                          J 1 Reply Last reply 2 May 2025, 12:27
                          1
                          • C Christian Ehrlicher
                            2 May 2025, 12:26

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

                            J Offline
                            J Offline
                            JonB
                            wrote on 2 May 2025, 12:27 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 2 May 2025, 13:42 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

                              C 1 Reply Last reply 2 May 2025, 13:45
                              0
                              • H HQ2000
                                2 May 2025, 13:42

                                @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

                                C Online
                                C Online
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on 2 May 2025, 13:45 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
                                  1 May 2025, 20:53

                                  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 2 May 2025, 14:03 last edited by HQ2000 5 Feb 2025, 14:04
                                  #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)
                                  
                                  J 1 Reply Last reply 2 May 2025, 14:12
                                  0
                                  • H HQ2000
                                    2 May 2025, 14:03

                                    @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)
                                    
                                    J Offline
                                    J Offline
                                    JonB
                                    wrote on 2 May 2025, 14:12 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?

                                    C 1 Reply Last reply 2 May 2025, 14:13
                                    0
                                    • C Online
                                      C Online
                                      Christian Ehrlicher
                                      Lifetime Qt Champion
                                      wrote on 2 May 2025, 14:12 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
                                      • J JonB
                                        2 May 2025, 14:12

                                        @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?

                                        C Online
                                        C Online
                                        Christian Ehrlicher
                                        Lifetime Qt Champion
                                        wrote on 2 May 2025, 14:13 last edited by Christian Ehrlicher 5 Feb 2025, 14:14
                                        #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

                                        J 1 Reply Last reply 2 May 2025, 14:15
                                        1
                                        • C Christian Ehrlicher
                                          2 May 2025, 14:13

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

                                          J Offline
                                          J Offline
                                          JonB
                                          wrote on 2 May 2025, 14:15 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.

                                          C 1 Reply Last reply 2 May 2025, 14:24
                                          0

                                          13/35

                                          2 May 2025, 12:09

                                          • Login

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