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. how to build project using command line
Forum Updated to NodeBB v4.3 + New Features

how to build project using command line

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.8k Views 2 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.
  • J Offline
    J Offline
    JacobNovitsky
    wrote on last edited by
    #1

    I need to reproduce building with green arrow in Qt Creator using command line
    Please advise

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you using CMake or qmake ?

      Both work in a similar fashion:

      • create a build folder out of the source folder
      • cd build folder

      For cmake (Qt 6):

      • /path/to/qt-cmake /path/to/source
      • cmake --build .

      For qmake (Qt 6 and older):

      • /path/to/qmake /path/to/source
      • make

      You can also use CMake standalone but you will have to point it to your Qt installation.

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

      J 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        Are you using CMake or qmake ?

        Both work in a similar fashion:

        • create a build folder out of the source folder
        • cd build folder

        For cmake (Qt 6):

        • /path/to/qt-cmake /path/to/source
        • cmake --build .

        For qmake (Qt 6 and older):

        • /path/to/qmake /path/to/source
        • make

        You can also use CMake standalone but you will have to point it to your Qt installation.

        J Offline
        J Offline
        JacobNovitsky
        wrote on last edited by JacobNovitsky
        #3

        @SGaist I use qmake
        if I call make with terminal from project root it builds all files (takes long time)
        if I build from Qt Creator it just builds only files that was changed (shortest time)
        how to make the same with command line?

        SGaistS 1 Reply Last reply
        0
        • J JacobNovitsky

          @SGaist I use qmake
          if I call make with terminal from project root it builds all files (takes long time)
          if I build from Qt Creator it just builds only files that was changed (shortest time)
          how to make the same with command line?

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @JacobNovitsky exactly as I wrote. The first build will be longer but the following will only rebuild what is necessary.

          Also, as suggested in the two methods I gave: don't build in your sources.

          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
          2
          • J Offline
            J Offline
            JacobNovitsky
            wrote on last edited by JacobNovitsky
            #5

            [1]I call make from root folder it compiles all source files to object files inside current root folder
            [2]If I build with Qt Creator it builds object files inside corresponding build folder (debug/release), never creating o. files in root

            Is it possible to proceed similar to [2] using command line?
            Usecase: I already have objects in build folder, I don't want to have .o files in my current directory

            kindly advise

            SGaistS 1 Reply Last reply
            0
            • J JacobNovitsky

              [1]I call make from root folder it compiles all source files to object files inside current root folder
              [2]If I build with Qt Creator it builds object files inside corresponding build folder (debug/release), never creating o. files in root

              Is it possible to proceed similar to [2] using command line?
              Usecase: I already have objects in build folder, I don't want to have .o files in my current directory

              kindly advise

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @JacobNovitsky yes, that's what I described in my first answer.

              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
              • S Offline
                S Offline
                SimonSchroeder
                wrote on last edited by
                #7

                You can set the different directories inside your .pro file (this would apply to both compiling on the command line and from QtCreator). It would look something like this:

                CONFIG(release, debug|release):DESTDIR     = release
                CONFIG(debug, debug|release):DESTDIR       = debug
                CONFIG(release, debug|release) {
                CONFIG(force_debug_info): DESTDIR = profile
                }
                
                OBJECTS_DIR = $$DESTDIR
                MOC_DIR     = $$DESTDIR
                RCC_DIR     = $$DESTDIR
                UI_DIR      = $$DESTDIR
                
                SGaistS 1 Reply Last reply
                1
                • S SimonSchroeder

                  You can set the different directories inside your .pro file (this would apply to both compiling on the command line and from QtCreator). It would look something like this:

                  CONFIG(release, debug|release):DESTDIR     = release
                  CONFIG(debug, debug|release):DESTDIR       = debug
                  CONFIG(release, debug|release) {
                  CONFIG(force_debug_info): DESTDIR = profile
                  }
                  
                  OBJECTS_DIR = $$DESTDIR
                  MOC_DIR     = $$DESTDIR
                  RCC_DIR     = $$DESTDIR
                  UI_DIR      = $$DESTDIR
                  
                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @SimonSchroeder While it allows to dictate where to store build artifacts, it does not solve the issue at hand which is in source builds.

                  The real solution here is to do what I wrote:

                  • Create a build folder outside of the sources (which is what Qt Creator does by default)
                  • trigger the project manager from that folder
                  • build

                  There's really nothing more to it than that.

                  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

                  • Login

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