Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building Qt Creator projects from command line

Tags:

I'm in the process of writing a build script to automate build and release tasks. I have a Qt Creator project which has three configurations, two of which I want to completely rebuild from scratch without any precompiled headers and existing .o files to skip (release and release_production). The latter is the same except it has the PRODUCTION symbol #defined.

I'm using windows. How can I build these configurations from the command line?

Edit: Some clarification: The Qt Creator custom build steps are not stored in the qmake makefile but in the Qt Creator-specific .pro.user XML file. I would like to perform these from the command line without repeating them in the script.

like image 768
Tamás Szelei Avatar asked May 25 '11 15:05

Tamás Szelei


People also ask

How do I open a Qt file in CMD?

To get such a command prompt, just select "Qt 4.8. 5 Command Prompt" from the startmenu. Either that or open a command prompt via Start -> Run -> "CMD.exe" and then call "C:\your_qt_install_path\bin\qtvars.


2 Answers

There are two steps involved here:

  1. Running qmake to generate Makefiles. The usual command is

    c:\qt\4.7.2\bin\qmake.exe" path\to\some\project.pro -r -spec win32-g++ CONFIG+=...
    

    The -spec switch is important. Make sure you supply a valid makespec file. CONFIG needs to be specified in this step.

  2. Running make to compile and link. This is easy

    C:\MinGW32\bin\mingw32-make -f Makefile.Debug
    

    Remember to point make to the correct makefile.

like image 128
Nam Nguyen Avatar answered Oct 27 '22 00:10

Nam Nguyen


In the project tab of QtCreator you have the exact command, QtCreator runs on build for both debug and release. Just run those lines in a environment your project can be build (Qt console). But basically Qt projects are build with a qmake.exe then a nmake.exe or the Qt multi-thread make-like executable jom.exe.

For your "production" mode your can use CONFIG+=production argument in the qmake command, then in your .pro files :

CONFIG(production){
DEFINES+=PRODUCTION
}else{
}
like image 39
Thomas Vincent Avatar answered Oct 27 '22 00:10

Thomas Vincent