Cannot run compiler 'cl'

So after lots of struggle and research I am finally able to install Qt and run the program using Qt Creator in Windows.

  • For Qt to run you need a compiler and a debugger, which is not provided by default.
  • If you just have to run a Qt-only program and the extra libraries that you will be using will compile using MinGW, then you can select MinGW as the compiler during the time of installation using online Qt installer.
  • But in most cases, we will be installing Visual Studio first. Select C++/CLI in the checkbox, as it's not selected by default.
  • Once Visual Studio is installed, we need a separate debugger CDB to link Qt with VS. For that, you need to uninstall the current Windows Software Development Kit and install again from here, or modify the installation in the Windows Settings app. During the installation, make sure to select Debugging Tool For Windows. The reason for uninstalling previously was that if we install again with the new option also selected, it will not override the previous installation.
  • Now open the Qt project. Go to Tools > Options > Build & Run > Debuggers and you can see that the debugger should be auto-detected.
  • Now go to the kits tab and select the debugger that was detected. For the compiler, select the required compiler, you will see a warning that the compiler is not compatible but you can ignore that as the program runs. (Don't forget to select Apply).

In my case, before running ANY qmake commands, I had to run %QT_DIR%\bin\qtenv2.bat manually, which needs to be modified to call the vcvarsall.bat.

With VS 2017 community, add this line to qtenv2.bat

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64

Replace x64 with whatever architecture you have.

To verify your VS-Qt toolchain is correctly installed:

  1. Open QtCreator
  2. Go to Options > Kits, ensure that you have expected Qt versions, compilers, and debuggers under the designated tabs. Those names are suffixed with VS versions and architectures.

Tags:

C++

Qt