QtCreator qmake Cannot run compiler 'cl'
This is the solution for anyone who has or had NVMW installed:
After a year of not being able to use Qt on my work laptop and private PC, I have finally figured out how to fix it, if you have installed the Node.js version manager for Windows at any point:
I found the file %HOMEPATH%\cmd_auto_run.cmd
in my user directory (thanks to this barely related SO answer), which has been constantly resetting the PATH
variable to a constant string, overriding any changes I was making to the system environment variables. The path to this file was set in the Windows Registry under HKCU\SOFTWARE\Microsoft\Command Processor\Autorun
After opening the file, I simply added a %PATH%;
just after the =
sign and just to be sure I removed any duplicate paths that were defined after that. Afterwards, the line was looking like this:
SET "PATH=%PATH%;C:\Users\MYUSER\nvmw\nodejs\v15.2.1"
Then, I added the following paths to the system environment variable named PATH
, for both the VS Build Tools (needed for cl.exe - I added 2017 and 2019 just to be safe) and the Windows 10 SDK (needed for rc.exe):
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64
Then I restarted Qt and it found all of the project's files again and I could compile it just like I used to.
This is a problem with NVMW, a Node.js version manager for Windows. There is an issue on a repo on GitHub from 2015 but it hasn't been fixed yet and the main repo was archived. This was the most frustrating sh!t ever and it probably took me over 20 hours actively to fix it so I hope I can help someone who has been struggling just like me.
I had a similar case, which was solved by adding the path to cl.exe to the path environment variable:
set path=%path%;%qtdir%\bin;"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin\Hostx64\x64"
set QMakeSpec=win32-msvc
qmake -tp vc
Maybe another cl.exe is interfering here?