Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. I'm going crazy with QT6 and Cmake
Qt 6.12 LTS is out! See what's new in the release blog

I'm going crazy with QT6 and Cmake

Scheduled Pinned Locked Moved Solved Installation and Deployment
13 Posts 4 Posters 7.6k 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.
  • arcyA Offline
    arcyA Offline
    arcy
    wrote on last edited by arcy
    #1

    Hi all! I'm trying to build my Windows Qt6 project with Cmake and without QTCreator, as an exercise. I'm building with Ninja generator. It builds correctly and I can find my .exe in the build directory. But when I run the executable I got an error that some Qt DLLs were not found (core, gui, quick and serialport). So I read this guide and tried to deploy with windeployqt, but at the end of the command execution I got "access denied". If I run my .exe with all DLLs copied in the build directory the error disappears but the app doesn't run...what I'm doing wrong?

    My CmakeLists.txt:

    cmake_minimum_required(VERSION 3.26)
    
    project(prometheus_app VERSION 0.0.1 LANGUAGES CXX)
    
    set(CMAKE_PREFIX_PATH "C:/Qt/6.5.0/mingw_64")
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    
    find_package(Qt6 REQUIRED COMPONENTS Gui Quick SerialPort)
    
    qt_standard_project_setup(REQUIRES 6.5)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    qt_add_executable(prometheus src/main.cpp src/RtMidi.h src/RtMidi.cpp src/backend.h src/backend.cpp)
    
    qt_add_qml_module(prometheus
        URI prometheus_app
        VERSION 1.0
        QML_FILES 
            ui/Main.qml
            ui/Fader.qml
    )
    
    target_link_libraries(prometheus PRIVATE Qt6::Gui Qt6::Quick Qt6::SerialPort setupapi Winmm)
    
    set_target_properties(prometheus PROPERTIES WIN32_EXECUTABLE ON)
    

    The windeployqt command:

    .\windeployqt.exe C:\Users\arcid\dev\prometheus_cpp\build\prometheus.exe --qmldir C:\Users\arcid\dev\prometheus_cpp\ui
    

    Thanks!

    Axel SpoerlA 1 Reply Last reply
    0
    • cristian-adamC Offline
      cristian-adamC Offline
      cristian-adam
      wrote on last edited by
      #12

      Run DebugView before attempting to start your application.

      You should see there some information why the application doesn't start.

      From commandline you can set the environment variable set QT_LOGGING_RULES=qt*=true to get Qt to log things in DebugView.

      Otherwise Event Viewer from Control Panel -> Windows Tools will log under Windows Logs -> Application details about processes that do not start.

      And lastly Process Monitor logs all the file and registry access of a process.

      Good luck in finding out why the application doesn't start 🤞

      arcyA 1 Reply Last reply
      1
      • arcyA arcy

        Hi all! I'm trying to build my Windows Qt6 project with Cmake and without QTCreator, as an exercise. I'm building with Ninja generator. It builds correctly and I can find my .exe in the build directory. But when I run the executable I got an error that some Qt DLLs were not found (core, gui, quick and serialport). So I read this guide and tried to deploy with windeployqt, but at the end of the command execution I got "access denied". If I run my .exe with all DLLs copied in the build directory the error disappears but the app doesn't run...what I'm doing wrong?

        My CmakeLists.txt:

        cmake_minimum_required(VERSION 3.26)
        
        project(prometheus_app VERSION 0.0.1 LANGUAGES CXX)
        
        set(CMAKE_PREFIX_PATH "C:/Qt/6.5.0/mingw_64")
        set(CMAKE_INCLUDE_CURRENT_DIR ON)
        
        find_package(Qt6 REQUIRED COMPONENTS Gui Quick SerialPort)
        
        qt_standard_project_setup(REQUIRES 6.5)
        
        set(CMAKE_CXX_STANDARD 17)
        set(CMAKE_CXX_STANDARD_REQUIRED ON)
        
        qt_add_executable(prometheus src/main.cpp src/RtMidi.h src/RtMidi.cpp src/backend.h src/backend.cpp)
        
        qt_add_qml_module(prometheus
            URI prometheus_app
            VERSION 1.0
            QML_FILES 
                ui/Main.qml
                ui/Fader.qml
        )
        
        target_link_libraries(prometheus PRIVATE Qt6::Gui Qt6::Quick Qt6::SerialPort setupapi Winmm)
        
        set_target_properties(prometheus PROPERTIES WIN32_EXECUTABLE ON)
        

        The windeployqt command:

        .\windeployqt.exe C:\Users\arcid\dev\prometheus_cpp\build\prometheus.exe --qmldir C:\Users\arcid\dev\prometheus_cpp\ui
        

        Thanks!

        Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #2

        @arcy
        Just a bet in the dark, because I have fallen into the same trap many times:
        The virus scanner doesn’t know the new executable, so it’s quarantined.
        The build directory has to be excluded from scanning.

        Software Engineer
        The Qt Company, Oslo

        arcyA 1 Reply Last reply
        0
        • Axel SpoerlA Axel Spoerl

          @arcy
          Just a bet in the dark, because I have fallen into the same trap many times:
          The virus scanner doesn’t know the new executable, so it’s quarantined.
          The build directory has to be excluded from scanning.

          arcyA Offline
          arcyA Offline
          arcy
          wrote on last edited by
          #3

          @Axel-Spoerl Hi and thanks for your reply, I configured my windows security by adding the built folder but it doesn't work. Maybe I have to set some environment variables?

          Axel SpoerlA 1 Reply Last reply
          0
          • arcyA arcy

            @Axel-Spoerl Hi and thanks for your reply, I configured my windows security by adding the built folder but it doesn't work. Maybe I have to set some environment variables?

            Axel SpoerlA Offline
            Axel SpoerlA Offline
            Axel Spoerl
            Moderators
            wrote on last edited by
            #4

            @arcy
            Could you post the exact error message that appears when you try to launch the newly built executable, please?

            Software Engineer
            The Qt Company, Oslo

            arcyA 1 Reply Last reply
            0
            • Axel SpoerlA Axel Spoerl

              @arcy
              Could you post the exact error message that appears when you try to launch the newly built executable, please?

              arcyA Offline
              arcyA Offline
              arcy
              wrote on last edited by
              #5

              @Axel-Spoerl I reinstall Qt and redo all from scratch. This is my CMakeLIsts.txt

              cmake_minimum_required(VERSION 3.26)
              
              project(prometheus_app VERSION 0.0.1 LANGUAGES CXX)
              
              set(CMAKE_CXX_STANDARD 17)
              set(CMAKE_CXX_STANDARD_REQUIRED ON)
              set(CMAKE_PREFIX_PATH "C:/Qt/6.5.1/mingw_64")
              
              find_package(Qt6 REQUIRED COMPONENTS Quick SerialPort)
              
              qt_standard_project_setup()
              
              
              qt_add_executable(prometheus WIN32 src/main.cpp src/RtMidi.h src/RtMidi.cpp src/backend.h src/backend.cpp)
              
              qt_add_qml_module(prometheus
                  URI prometheus_app
                  VERSION 1.0
                  QML_FILES ui/Main.qml ui/Fader.qml
              )
              
              add_definitions(-D__WINDOWS_MM__)
              
              target_link_libraries(prometheus PRIVATE Qt6::Quick Qt6::SerialPort Winmm)
              
              install(TARGETS prometheus
                  BUNDLE DESTINATION .
                  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
              )
              
              qt_generate_deploy_app_script(
                  TARGET prometheus
                  OUTPUT_SCRIPT deployApp
              )
              install(SCRIPT "${deployApp}")
              

              When I run

              cmake -GNinja .. && ninja
              

              it builds correctly, but when I run the .exe I get Qt6Qml.dll, Qt6Core.dll, Qt6Gui.dll and Qt6SerialPort.dll were not found. And this is my first problem because I can't debug my program.

              So I tried to use windepolyqt.exe to copy all the DLLs needed inside my build folder, but when I run the .exe simply nothing happens...

              Chris KawaC 1 Reply Last reply
              0
              • arcyA arcy

                @Axel-Spoerl I reinstall Qt and redo all from scratch. This is my CMakeLIsts.txt

                cmake_minimum_required(VERSION 3.26)
                
                project(prometheus_app VERSION 0.0.1 LANGUAGES CXX)
                
                set(CMAKE_CXX_STANDARD 17)
                set(CMAKE_CXX_STANDARD_REQUIRED ON)
                set(CMAKE_PREFIX_PATH "C:/Qt/6.5.1/mingw_64")
                
                find_package(Qt6 REQUIRED COMPONENTS Quick SerialPort)
                
                qt_standard_project_setup()
                
                
                qt_add_executable(prometheus WIN32 src/main.cpp src/RtMidi.h src/RtMidi.cpp src/backend.h src/backend.cpp)
                
                qt_add_qml_module(prometheus
                    URI prometheus_app
                    VERSION 1.0
                    QML_FILES ui/Main.qml ui/Fader.qml
                )
                
                add_definitions(-D__WINDOWS_MM__)
                
                target_link_libraries(prometheus PRIVATE Qt6::Quick Qt6::SerialPort Winmm)
                
                install(TARGETS prometheus
                    BUNDLE DESTINATION .
                    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
                )
                
                qt_generate_deploy_app_script(
                    TARGET prometheus
                    OUTPUT_SCRIPT deployApp
                )
                install(SCRIPT "${deployApp}")
                

                When I run

                cmake -GNinja .. && ninja
                

                it builds correctly, but when I run the .exe I get Qt6Qml.dll, Qt6Core.dll, Qt6Gui.dll and Qt6SerialPort.dll were not found. And this is my first problem because I can't debug my program.

                So I tried to use windepolyqt.exe to copy all the DLLs needed inside my build folder, but when I run the .exe simply nothing happens...

                Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @arcy said:

                it builds correctly, but when I run the .exe I get Qt6Qml.dll, Qt6Core.dll, Qt6Gui.dll and Qt6SerialPort.dll were not found

                Well yes. Building builds your exe. That exe needs the dependant Qt dlls to run, so you need to deploy those dlls to your app folder. You can copy them manually or use windeployqt to do it for you.

                So I tried to use windepolyqt.exe to copy all the DLLs needed inside my build folder, but when I run the .exe simply nothing happens...

                You need to give windeployqt the name of your exe as a command line argument.

                arcyA 1 Reply Last reply
                1
                • Chris KawaC Chris Kawa

                  @arcy said:

                  it builds correctly, but when I run the .exe I get Qt6Qml.dll, Qt6Core.dll, Qt6Gui.dll and Qt6SerialPort.dll were not found

                  Well yes. Building builds your exe. That exe needs the dependant Qt dlls to run, so you need to deploy those dlls to your app folder. You can copy them manually or use windeployqt to do it for you.

                  So I tried to use windepolyqt.exe to copy all the DLLs needed inside my build folder, but when I run the .exe simply nothing happens...

                  You need to give windeployqt the name of your exe as a command line argument.

                  arcyA Offline
                  arcyA Offline
                  arcy
                  wrote on last edited by
                  #7

                  @Chris-Kawa

                  .\windeployqt.exe C:\Users\arcid\dev\prometheus_cpp\build\prometheus.exe --qmldir C:\Users\arcid\dev\prometheus_cpp\ui
                  

                  I guess I passed the exe as first argument

                  Chris KawaC 1 Reply Last reply
                  0
                  • arcyA arcy

                    @Chris-Kawa

                    .\windeployqt.exe C:\Users\arcid\dev\prometheus_cpp\build\prometheus.exe --qmldir C:\Users\arcid\dev\prometheus_cpp\ui
                    

                    I guess I passed the exe as first argument

                    Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @arcy said:

                    but when I run the .exe simply nothing happens

                    Do you mean that nothing happens when you run windeployqt or nothing happens when you run your app after that?
                    Did windeployqt copy the dlls or not?

                    arcyA 1 Reply Last reply
                    0
                    • Chris KawaC Chris Kawa

                      @arcy said:

                      but when I run the .exe simply nothing happens

                      Do you mean that nothing happens when you run windeployqt or nothing happens when you run your app after that?
                      Did windeployqt copy the dlls or not?

                      arcyA Offline
                      arcyA Offline
                      arcy
                      wrote on last edited by
                      #9

                      @Chris-Kawa
                      Nothing happens when I try to run the exe after the wideployqt command. All the needed dlls are correctly in the build folder.

                      Chris KawaC 1 Reply Last reply
                      0
                      • arcyA arcy

                        @Chris-Kawa
                        Nothing happens when I try to run the exe after the wideployqt command. All the needed dlls are correctly in the build folder.

                        Chris KawaC Offline
                        Chris KawaC Offline
                        Chris Kawa
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        @arcy Are the compiler runtime dlls also in your build directory? As with Qt dlls you can copy them manually or pass --compiler-runtime to windeployqt to do it for you.

                        arcyA 1 Reply Last reply
                        0
                        • Chris KawaC Chris Kawa

                          @arcy Are the compiler runtime dlls also in your build directory? As with Qt dlls you can copy them manually or pass --compiler-runtime to windeployqt to do it for you.

                          arcyA Offline
                          arcyA Offline
                          arcy
                          wrote on last edited by
                          #11

                          @Chris-Kawa I re-run the windeployqt passing --compiler-runtime, my build folder now has this files:

                          1.png
                          4.png 3.png 2.png

                          But when I try to run prometheus.exe nothing happens... :-(

                          1 Reply Last reply
                          0
                          • cristian-adamC Offline
                            cristian-adamC Offline
                            cristian-adam
                            wrote on last edited by
                            #12

                            Run DebugView before attempting to start your application.

                            You should see there some information why the application doesn't start.

                            From commandline you can set the environment variable set QT_LOGGING_RULES=qt*=true to get Qt to log things in DebugView.

                            Otherwise Event Viewer from Control Panel -> Windows Tools will log under Windows Logs -> Application details about processes that do not start.

                            And lastly Process Monitor logs all the file and registry access of a process.

                            Good luck in finding out why the application doesn't start 🤞

                            arcyA 1 Reply Last reply
                            1
                            • cristian-adamC cristian-adam

                              Run DebugView before attempting to start your application.

                              You should see there some information why the application doesn't start.

                              From commandline you can set the environment variable set QT_LOGGING_RULES=qt*=true to get Qt to log things in DebugView.

                              Otherwise Event Viewer from Control Panel -> Windows Tools will log under Windows Logs -> Application details about processes that do not start.

                              And lastly Process Monitor logs all the file and registry access of a process.

                              Good luck in finding out why the application doesn't start 🤞

                              arcyA Offline
                              arcyA Offline
                              arcy
                              wrote on last edited by
                              #13

                              @cristian-adam
                              [6256] QQmlApplicationEngine failed to load component
                              [6256] <Unknown File>: No module named "prometheus_cpp" found

                              I changed my module name and now correctly run thanks!

                              1 Reply Last reply
                              1
                              • arcyA arcy has marked this topic as solved on

                              • Login

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