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. Build and Run from Command Line
Forum Updated to NodeBB v4.3 + New Features

Build and Run from Command Line

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
13 Posts 6 Posters 3.0k Views 5 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.
  • Sebastiano ZamberlanS Offline
    Sebastiano ZamberlanS Offline
    Sebastiano Zamberlan
    wrote on last edited by
    #1

    What is the correct way to launch from 0 the build and then run of a Qt6 project (Cmake) via command line.

    Take for example a QtQuick Application project

    How can i from Powershell build and then run the project?

    sierdzioS 1 Reply Last reply
    1
    • Sebastiano ZamberlanS Sebastiano Zamberlan

      What is the correct way to launch from 0 the build and then run of a Qt6 project (Cmake) via command line.

      Take for example a QtQuick Application project

      How can i from Powershell build and then run the project?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @Sebastiano-Zamberlan the process is similar to any other cmake project:

      cmake -S /path/to/source-code -B . 
      cmake --build . --parallel --config Release
      

      Then you either run the executable right away or perhaps run deployment first (windeployqt).

      (Z(:^

      Sebastiano ZamberlanS 1 Reply Last reply
      2
      • sierdzioS sierdzio

        @Sebastiano-Zamberlan the process is similar to any other cmake project:

        cmake -S /path/to/source-code -B . 
        cmake --build . --parallel --config Release
        

        Then you either run the executable right away or perhaps run deployment first (windeployqt).

        Sebastiano ZamberlanS Offline
        Sebastiano ZamberlanS Offline
        Sebastiano Zamberlan
        wrote on last edited by
        #3

        @sierdzio How can I specify that I want it to be compiled with mingw_64

        Christian EhrlicherC Paul ColbyP 2 Replies Last reply
        0
        • Sebastiano ZamberlanS Sebastiano Zamberlan

          @sierdzio How can I specify that I want it to be compiled with mingw_64

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

          @Sebastiano-Zamberlan said in Build and Run from Command Line:

          How can I specify that I want it to be compiled with mingw_64

          What does this mean? You create a CMakeLists.txt like it's done in QtCreator or any other ide which cmake then processes.

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

          Sebastiano ZamberlanS 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            @Sebastiano-Zamberlan said in Build and Run from Command Line:

            How can I specify that I want it to be compiled with mingw_64

            What does this mean? You create a CMakeLists.txt like it's done in QtCreator or any other ide which cmake then processes.

            Sebastiano ZamberlanS Offline
            Sebastiano ZamberlanS Offline
            Sebastiano Zamberlan
            wrote on last edited by
            #5

            @Christian-Ehrlicher, @sierdzio let's take an example, I create a new project ( in this case QtQuick Application )
            I leave the code as is and try from terminal to run

            cmake -S /path/to/source-code -B .
            

            this is what appears to me.

            -- Building for: Visual Studio 15 2017
            -- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19045.
            -- The CXX compiler identification is MSVC 19.16.27051.0
            -- Detecting CXX compiler ABI info
            -- Detecting CXX compiler ABI info - done
            -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - skipped
            -- Detecting CXX compile features
            -- Detecting CXX compile features - done
            CMake Error at CMakeLists.txt:8 (find_package):
              By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has
              asked CMake to find a package configuration file provided by "Qt6", but
              CMake did not find one.
            
              Could not find a package configuration file provided by "Qt6" (requested
              version 6.2) with any of the following names:
            
                Qt6Config.cmake
                qt6-config.cmake
            
              Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR"
              to a directory containing one of the above files.  If "Qt6" provides a
              separate development package or SDK, be sure it has been installed.
            
            
            -- Configuring incomplete, errors occurred!
            

            I wanted to know meanwhile how to specify my intention to use mingw_64 as compiler

            Christian EhrlicherC 1 Reply Last reply
            1
            • Sebastiano ZamberlanS Sebastiano Zamberlan

              @Christian-Ehrlicher, @sierdzio let's take an example, I create a new project ( in this case QtQuick Application )
              I leave the code as is and try from terminal to run

              cmake -S /path/to/source-code -B .
              

              this is what appears to me.

              -- Building for: Visual Studio 15 2017
              -- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19045.
              -- The CXX compiler identification is MSVC 19.16.27051.0
              -- Detecting CXX compiler ABI info
              -- Detecting CXX compiler ABI info - done
              -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - skipped
              -- Detecting CXX compile features
              -- Detecting CXX compile features - done
              CMake Error at CMakeLists.txt:8 (find_package):
                By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has
                asked CMake to find a package configuration file provided by "Qt6", but
                CMake did not find one.
              
                Could not find a package configuration file provided by "Qt6" (requested
                version 6.2) with any of the following names:
              
                  Qt6Config.cmake
                  qt6-config.cmake
              
                Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR"
                to a directory containing one of the above files.  If "Qt6" provides a
                separate development package or SDK, be sure it has been installed.
              
              
              -- Configuring incomplete, errors occurred!
              

              I wanted to know meanwhile how to specify my intention to use mingw_64 as compiler

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

              You have to set up your env correctly before by starting the command line through the 'Qt 6.x.x (MinGW64) menu entry. Then the PATH is correctly set up and the mingw compiler is found & used. Start over with a clean build dir.

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

              Sebastiano ZamberlanS 1 Reply Last reply
              2
              • Christian EhrlicherC Christian Ehrlicher

                You have to set up your env correctly before by starting the command line through the 'Qt 6.x.x (MinGW64) menu entry. Then the PATH is correctly set up and the mingw compiler is found & used. Start over with a clean build dir.

                Sebastiano ZamberlanS Offline
                Sebastiano ZamberlanS Offline
                Sebastiano Zamberlan
                wrote on last edited by Sebastiano Zamberlan
                #7

                @Christian-Ehrlicher @sierdzio

                I tried but still the same error,
                I also ran the command

                --system-information information.txt 
                

                and in the .txt the path goes to the Visual Studio

                In fact the message that cmake sent me was always:

                -- Building for: Visual Studio 15 2017
                
                Christian EhrlicherC 1 Reply Last reply
                1
                • Sebastiano ZamberlanS Sebastiano Zamberlan

                  @Christian-Ehrlicher @sierdzio

                  I tried but still the same error,
                  I also ran the command

                  --system-information information.txt 
                  

                  and in the .txt the path goes to the Visual Studio

                  In fact the message that cmake sent me was always:

                  -- Building for: Visual Studio 15 2017
                  
                  Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Sebastiano-Zamberlan Then pass -DCMAKE_CXX_COMPILER=g++ and make sure g++ --version print something useful (which should when you set up the env correct).

                  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
                  2
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Hi,

                    In addition to @Christian-Ehrlicher, the Qt 6 versions you installed have a qt-cmake script that are tuned for the installation they are in.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • Sebastiano ZamberlanS Sebastiano Zamberlan

                      @sierdzio How can I specify that I want it to be compiled with mingw_64

                      Paul ColbyP Offline
                      Paul ColbyP Offline
                      Paul Colby
                      wrote on last edited by
                      #10

                      @Sebastiano-Zamberlan said in Build and Run from Command Line:

                      @sierdzio How can I specify that I want it to be compiled with mingw_64

                      The easiest way, I think, is to use CMake's MinGW Makefiles generator, like:

                      cmake -G "MinGW Makefiles" ...
                      

                      As @SGaist wrote, if you're using Qt 6, then you can use Qt's qt-cmake wrapper, so:

                      X:\path\to\qt\installation\qt-cmake.bat -G "MinGW Makefiles" -S <src-dir> -B <build-dir>
                      

                      All qt-cmake does (today) is set CMake's CMAKE_TOOLCHAIN_FILE variable, so it's equivalent to:

                      cmake.exe -DCMAKE_TOOLCHAIN_FILE="X:\path\to\qt\installation\lib\cmake\qt.toolchain.cmake" -G "MinGW Makefiles" -S <src-dir> -B <build-dir>
                      

                      Cheers.

                      Sebastiano ZamberlanS 1 Reply Last reply
                      4
                      • Paul ColbyP Paul Colby

                        @Sebastiano-Zamberlan said in Build and Run from Command Line:

                        @sierdzio How can I specify that I want it to be compiled with mingw_64

                        The easiest way, I think, is to use CMake's MinGW Makefiles generator, like:

                        cmake -G "MinGW Makefiles" ...
                        

                        As @SGaist wrote, if you're using Qt 6, then you can use Qt's qt-cmake wrapper, so:

                        X:\path\to\qt\installation\qt-cmake.bat -G "MinGW Makefiles" -S <src-dir> -B <build-dir>
                        

                        All qt-cmake does (today) is set CMake's CMAKE_TOOLCHAIN_FILE variable, so it's equivalent to:

                        cmake.exe -DCMAKE_TOOLCHAIN_FILE="X:\path\to\qt\installation\lib\cmake\qt.toolchain.cmake" -G "MinGW Makefiles" -S <src-dir> -B <build-dir>
                        

                        Cheers.

                        Sebastiano ZamberlanS Offline
                        Sebastiano ZamberlanS Offline
                        Sebastiano Zamberlan
                        wrote on last edited by
                        #11

                        @Paul-Colby @Christian-Ehrlicher @SGaist @sierdzio

                        Thank you guys, this information is very helpful,

                        I was able to launch from the specific terminal, now I want to understand what the "qtenv2.bat" contains and how it acts so that I can make a .bat or a general .py that allows me to launch a build.

                        jsulmJ 1 Reply Last reply
                        0
                        • Sebastiano ZamberlanS Sebastiano Zamberlan

                          @Paul-Colby @Christian-Ehrlicher @SGaist @sierdzio

                          Thank you guys, this information is very helpful,

                          I was able to launch from the specific terminal, now I want to understand what the "qtenv2.bat" contains and how it acts so that I can make a .bat or a general .py that allows me to launch a build.

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @Sebastiano-Zamberlan said in Build and Run from Command Line:

                          I want to understand what the "qtenv2.bat" contains and how it acts

                          Open it in a text editor

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          Sebastiano ZamberlanS 1 Reply Last reply
                          2
                          • jsulmJ jsulm

                            @Sebastiano-Zamberlan said in Build and Run from Command Line:

                            I want to understand what the "qtenv2.bat" contains and how it acts

                            Open it in a text editor

                            Sebastiano ZamberlanS Offline
                            Sebastiano ZamberlanS Offline
                            Sebastiano Zamberlan
                            wrote on last edited by
                            #13

                            @jsulm yeah 👍

                            1 Reply Last reply
                            0
                            • Sebastiano ZamberlanS Sebastiano Zamberlan 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 Extensions
                            • Unsolved