how to build project using command line
-
I need to reproduce building with green arrow in Qt Creator using command line
Please advise -
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.
-
@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? -
@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.
-
[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 rootIs 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 directorykindly advise
-
@JacobNovitsky yes, that's what I described in my first answer.
-
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
-
@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.