QtCreator qmake Cannot run compiler 'cl'

后端 未结 4 1487
死守一世寂寞
死守一世寂寞 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条回答
  • 2021-02-07 16:49

    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?

    0 讨论(0)
  • 2021-02-07 16:54

    After next steps all runs fine.

    1. Set Dracula style for QtCreator :)
    2. Modify MSVS installation addning VC++ 2015.3 v140 toolset for desktop (x86,x64).

    Very strange. And that is why I don't like windows. It lives its own live!

    So the answer is TRY TO REINSTALL/modify components, including QtCreator itself.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-07 17:04

    Just reboot. It helped me. Probably finalizes the installation of Visual Studio or Qt.

    0 讨论(0)
提交回复
热议问题