Windows - Compile a QT project

October 2016

In this article, you will learn how to compile a QT project under Windows..

The Path variable

In order to use the command prompt and not the Qt Command Prompt, you will have to change your PATH variable. Indeed, it is impossible to run programs or scripts from the command prompt.

Accessing the PATH variable

This variable is accessible from the Control Panel.
Open the Control Panel and switch to Classic View.
  • Go to System > Advanced tab and click down on "Environment Variables" .
  • Another window opens, select the "Path" variable.

Changing the Path variable

Upon double-clicking on the Path variable, another window opens, it must contain the following:
You will need to add two paths :
  • the "bin" folder located in the "mingw" subfolder located in the Qt main folder;
  • the "bin" folder located in the "Qt" subfolder located in the Qt main folder;

Example of paths for the Qt 2009,3 pack:
  • Qt
    • 2009.3
      • mingw
        • bin
      • Qt
        • bin

To add the above paths, complete
By a ';' which indicate the end of a path and then add the absolute path of each file.


The batch script

Now that Path is correctly completed, you will need to create a batch script that will compile your project.

cd ../../../Dev-Cpp/Projets/Qt/VTest
mingw32-make release
mingw32-make clean //supprime tous les fichiers inutiles.

Analysis of the code :
  • cd ../../../Dev-Cpp/Projets/Qt/VTest : to move to our project.
  • qmake -project: creates the .pro file
  • qmake : creating Makefile
  • mingw32- make release : compile and places the executable in the release folder .
  • exit

Place this script in one of the folders specified in Path.

The program

We will call the program from the command prompt (optional).

#include <stdio.h>
#include <stdlib.h>

int main() {

printf("\n\tCompilateur de projets Qt\n\n");
system("start script.bat");
return 0;

Once compiled, place it in a folder indicated in Path .

Compile a project

To compile your project, open a command prompt and just type the name :
  • of batch script
  • or of the program

This will compile the files stored in the location specified in the batch script and place the executable in a release subfolder.

Related :

This document entitled « Windows - Compile a QT project » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.