Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. I'm having issues building a QT program
Forum Updated to NodeBB v4.3 + New Features

I'm having issues building a QT program

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
1 Posts 1 Posters 356 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.
  • C Offline
    C Offline
    cogos18
    wrote on last edited by
    #1

    I am having issues compiling a QT program in C++.

    So I want to have a system in place where everytime an executable file is built, the DLL files that are required as dependencies get placed into the build directory.

    But for some reason every time I try to compile something, an syntax error occurs because CMake tries to execute a CMD.exe instance inside another one which executes the commands.

    Here is the output I got:

    20:48:05: Running steps for project LauncherUIExample...
    20:48:05: Starting: "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build C:/code/mitch/projects/LauncherUIExample/build/Desktop_Qt_6_8_0_llvm_mingw_64_bit-Release --target all
    [0/2 0.0/sec] Re-checking globbed directories...
    -- GLOB mismatch!
    -- GLOB mismatch!
    [1/2 11.0/sec] Re-running CMake...
    -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
    -- Configuring done (0.7s)
    -- Generating done (0.0s)
    -- Build files have been written to: C:/code/mitch/projects/LauncherUIExample/build/Desktop_Qt_6_8_0_llvm_mingw_64_bit-Release
    [0/4 0.0/sec] Re-checking globbed directories...
    [1/4 8.8/sec] Linking CXX executable LauncherUIExample.exe
    FAILED: LauncherUIExample.exe 
    C:\Windows\system32\cmd.exe /C "C:\Windows\system32\cmd.exe /C "cd /D C:\code\mitch\projects\LauncherUIExample\build\Desktop_Qt_6_8_0_llvm_mingw_64_bit-Release && CD C:/code/mitch/projects/LauncherUIExample && COPY changes.txt C:/code/mitch/projects/LauncherUIExample/build/Desktop_Qt_6_8_0_llvm_mingw_64_bit-Release && cd C:\code\mitch\projects\LauncherUIExample\build\Desktop_Qt_6_8_0_llvm_mingw_64_bit-Release" && C:\Qt\Tools\llvm-mingw1706_64\bin\clang++.exe -O3 -DNDEBUG -mwindows CMakeFiles/LauncherUIExample.dir/LauncherUIExample_autogen/mocs_compilation.cpp.obj CMakeFiles/LauncherUIExample.dir/main.cpp.obj CMakeFiles/LauncherUIExample.dir/launchermainwindow.cpp.obj -o LauncherUIExample.exe -Wl,--out-implib,libLauncherUIExample.dll.a -Wl,--major-image-version,0,--minor-image-version,0  C:/Qt/6.8.0/llvm-mingw_64/lib/libQt6Widgets.a  C:/Qt/6.8.0/llvm-mingw_64/lib/libQt6Gui.a  C:/Qt/6.8.0/llvm-mingw_64/lib/libQt6Core.a  -lmpr  -luserenv  -lmingw32  C:/Qt/6.8.0/llvm-mingw_64/lib/libQt6EntryPoint.a  -pthread  -lshell32  -ld3d11  -ldxgi  -ldxguid  -ld3d12  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && C:\Windows\system32\cmd.exe /C "cd /D C:\code\mitch\projects\LauncherUIExample\build\Desktop_Qt_6_8_0_llvm_mingw_64_bit-Release && CD C:/code/mitch/projects/LauncherUIExample/build/Desktop_Qt_6_8_0_llvm_mingw_64_bit-Release && C:/Qt/6.8.0/llvm-mingw_64/bin/windeployqt.exe LauncherUIExample.exe --verbose 1 --dir .""
    The syntax of the command is incorrect.
    ninja: build stopped: subcommand failed.
    20:48:06: The process "C:\Qt\Tools\CMake_64\bin\cmake.exe" exited with code 1.
    Error while building/deploying project LauncherUIExample (kit: Desktop Qt 6.8.0 llvm-mingw 64-bit)
    When executing step "Build"
    

    Just in-case you wish to see the CMakeLists file contents, here it is:

    cmake_minimum_required(VERSION 3.16)
    
    project(LauncherUIExample VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
    
    set(TS_FILES LauncherUIExample_en_AU.ts)
    
    set(PROJECT_SOURCES
            main.cpp
            launchermainwindow.cpp
            launchermainwindow.h
            launchermainwindow.ui
            ${TS_FILES}
    )
    
    if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
        qt_add_executable(LauncherUIExample
            MANUAL_FINALIZATION
            ${PROJECT_SOURCES}
            changes.txt
        )
    # Define target properties for Android with Qt 6 as:
    #    set_property(TARGET LauncherUIExample APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
    #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
    # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
    
        qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
    else()
        if(ANDROID)
            add_library(LauncherUIExample SHARED
                ${PROJECT_SOURCES}
            )
    # Define properties for Android with Qt 5 after find_package() calls as:
    #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
        else()
            add_executable(LauncherUIExample
                ${PROJECT_SOURCES}
            )
        endif()
    
        qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
    endif()
    
    target_link_libraries(LauncherUIExample PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
    
    # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
    # If you are developing for iOS or macOS you should consider setting an
    # explicit, fixed bundle identifier manually though.
    if(${QT_VERSION} VERSION_LESS 6.1.0)
      set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.LauncherUIExample)
    endif()
    set_target_properties(LauncherUIExample PROPERTIES
        ${BUNDLE_ID_OPTION}
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    include(GNUInstallDirs)
    install(TARGETS LauncherUIExample
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    
    if(QT_VERSION_MAJOR EQUAL 6)
        qt_finalize_executable(LauncherUIExample)
    endif()
    
    
    add_custom_command(
        TARGET LauncherUIExample
        PRE_LINK
        COMMAND
            CD ${PROJECT_SOURCE_DIR} &&
            COPY changes.txt ${PROJECT_BINARY_DIR}
        )
    
    add_custom_command(
        TARGET LauncherUIExample
        POST_BUILD
        COMMAND
            CD ${PROJECT_BINARY_DIR} &&
            ${WINDEPLOYQT_EXECUTABLE} LauncherUIExample.exe
             --verbose 1 --dir .
        )
    
    

    Please be aware that I am still getting my hand around C++.
    Many thanks.

    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