kyb
kyb

Reputation: 8141

QtCreator qmake Cannot run compiler 'cl'

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

Project ERROR: Cannot run compiler 'cl'. Maybe you forgot to setup the environment?

With mingw build and run fine.


I tried to add Custom build step before qmake

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat" amd64

But got the same results. In cmd this command works fine. After it cl.exe is reachable.


All toolsets was found automatically by Qt and seems to be right

here were screenshots


Update1. Build in Developer Command Prompt for VS 2017

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0.26730.16
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************

C:\Users\Admin\source>"C:\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin\qmake.exe" C:\Devel\Qt\Qt5.9.1\Examples\Qt-5.9.1\datavisualization\bars\bars.pro -spec win32-msvc

C:\Users\Admin\source>nmake

Microsoft (R) Program Maintenance Utility Version 14.11.25508.2
Copyright (C) Microsoft Corporation.  All rights reserved.

        "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\bin\HostX86\x86\nmake.exe" -f Makefile.Release

Microsoft (R) Program Maintenance Utility Version 14.11.25508.2
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_DATAVISUALIZATION_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I..\..\..\Devel\Qt\Qt5.9.1\Examples\Qt-5.9.1\datavisualization\bars -I. -I../../../include -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtDataVisualization -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtWidgets -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtGui -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtANGLE -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtCore -Irelease -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\mkspecs\win32-msvc -Forelease\ @C:\Users\Admin\AppData\Local\Temp\nm6ED7.tmp
main.cpp
graphmodifier.cpp
Generating Code...
        cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_DATAVISUALIZATION_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I..\..\..\Devel\Qt\Qt5.9.1\Examples\Qt-5.9.1\datavisualization\bars -I. -I../../../include -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtDataVisualization -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtWidgets -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtGui -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtANGLE -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\include\QtCore -Irelease -I..\..\..\Devel\Qt\Qt5.9.1\5.9.1\msvc2017_64\mkspecs\win32-msvc -Forelease\ @C:\Users\Admin\AppData\Local\Temp\nm7EF5.tmp
moc_graphmodifier.cpp
        link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:release\bars.exe @C:\Users\Admin\AppData\Local\Temp\nm8417.tmp
Qt5DataVisualization.lib(Qt5DataVisualization.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\bin\HostX86\x86\link.EXE"' : return code '0x458'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.

C:\Users\Admin\source>

Linkage errors. But cl.exe found.

Upvotes: 17

Views: 46125

Answers (6)

Eric Petit
Eric Petit

Reputation: 25

Executing the following file setup environment, also you have qtcreator vs/cl.exe or mingw/g++? C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat

Upvotes: 0

Sv443
Sv443

Reputation: 749

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.

Upvotes: 4

RED SOFT ADAIR
RED SOFT ADAIR

Reputation: 12218

I had the same problem on Windows 10 with VC2019 and Qt 6.0.2. When i then started

Start->Visual Studio 2019->x64 Native Tools Command prompt

i saw a error message in the console window saying something like

"\ is syntactically not correct"

This was caused by a backslash at the end of the %path% variable set up in System settings->system->extended... I removed this backslash and then "x64 Native Tools Command prompt" opened without error, and after restarting qtCreator projects built without error.

Unfortunately after fixing this once i can not reproduce it any more.

Upvotes: 1

kyb
kyb

Reputation: 8141

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.

Upvotes: 1

user
user

Reputation: 25728

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

Upvotes: 3

ScaledLizard
ScaledLizard

Reputation: 181

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?

Upvotes: 10

Related Questions