Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run compiler 'cl'

Tags:

c++

qt

I have installed Qt on Windows according to the instructions, but when I have created a Qt Widget application I am getting the following error:

Running Windows Runtime device detection.
No winrtrunner.exe found.
Project ERROR: Cannot run compiler 'cl'. Maybe you forgot to setup the environment?

Also, in my Qt Creator project directory I cannot see anything apart from my .pro file.

I have tried with this answer, but could not get any result.

In my Qt installation folder, when I open the Tools folder, it just has QtCreator folder and no compiler folder.

  • Qt installed: 5.9.1
  • IDE: Qt Creator

How to fix this error?

like image 931
arqam Avatar asked Sep 11 '17 11:09

arqam


2 Answers

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.
like image 148
kakyo Avatar answered Oct 18 '22 20:10

kakyo


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).
like image 4
arqam Avatar answered Oct 18 '22 18:10

arqam