QtCreator qmake Cannot run compiler 'cl'

后端 未结 4 1480
死守一世寂寞
死守一世寂寞 2021-02-07 16:11

Just configured new windows environment with MSVS 2017 and Qt5.9.1.
While building example project bars met an error

Project ERROR: Cannot run c         


        
4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-07 16:59

    This is the solution for anyone who has 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 (in my case):

    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 set 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.

提交回复
热议问题