I'm going crazy with QT6 and Cmake
-
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!
-
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 inDebugView
.Otherwise
Event Viewer
from Control Panel -> Windows Tools will log underWindows 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 🤞
-
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!
@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. -
@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.@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-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?
@arcy
Could you post the exact error message that appears when you try to launch the newly built executable, please? -
@arcy
Could you post the exact error message that appears when you try to launch the newly built executable, please?@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...
-
@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...
@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.
-
@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.
.\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
-
.\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
@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? -
@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?@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-Kawa
Nothing happens when I try to run the exe after the wideployqt command. All the needed dlls are correctly in the build folder.@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. -
@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.@Chris-Kawa I re-run the windeployqt passing --compiler-runtime, my build folder now has this files:
But when I try to run prometheus.exe nothing happens... :-(
-
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 inDebugView
.Otherwise
Event Viewer
from Control Panel -> Windows Tools will log underWindows 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 🤞
-
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 inDebugView
.Otherwise
Event Viewer
from Control Panel -> Windows Tools will log underWindows 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 🤞
@cristian-adam
[6256] QQmlApplicationEngine failed to load component
[6256] <Unknown File>: No module named "prometheus_cpp" foundI changed my module name and now correctly run thanks!
-
A arcy has marked this topic as solved on