C++ QtCreator qmake 无法运行编译器“cl”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46569139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
QtCreator qmake Cannot run compiler 'cl'
提问by kyb
Just configured new windows environment with MSVS 2017 and Qt5.9.1.
While building example project bars
met an error
刚刚使用 MSVS 2017 和 Qt5.9.1 配置了新的 Windows 环境。
在构建示例项目时bars
遇到错误
Project ERROR: Cannot run compiler 'cl'. Maybe you forgot to setup the environment?
With mingw build and run fine.
使用 mingw 构建并运行良好。
I tried to add Custom build stepbefore qmake
我尝试在qmake之前添加自定义构建步骤
"C:\Program Files (x86)\Microsoft Visual Studio17\Professional\VC\Auxiliary\Build\vcvarsall.bat" amd64
But got the same results. In cmd
this command works fine. After it cl.exe
is reachable.
但得到了相同的结果。在cmd
这个命令中工作正常。之后,它cl.exe
是可到达。
All toolsets was found automatically by Qt and seems to be right
所有工具集都是由 Qt 自动找到的,似乎是正确的
Update1. Build in Developer Command Prompt for VS 2017
更新1。为 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.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 Studio17\Professional\VC\Tools\MSVC.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.9.1\msvc2017_64\include -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtDataVisualization -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtWidgets -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtGui -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtANGLE -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtCore -Irelease -I..\..\..\Devel\Qt\Qt5.9.1.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.9.1\msvc2017_64\include -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtDataVisualization -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtWidgets -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtGui -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtANGLE -I..\..\..\Devel\Qt\Qt5.9.1.9.1\msvc2017_64\include\QtCore -Irelease -I..\..\..\Devel\Qt\Qt5.9.1.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 Studio17\Professional\VC\Tools\MSVC.11.25503\bin\HostX86\x86\link.EXE"' : return code '0x458'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio17\Professional\VC\Tools\MSVC.11.25503\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
C:\Users\Admin\source>
Linkage errors. But cl.exe
found.
联动错误。却cl.exe
发现。
采纳答案by kyb
After next steps all runs fine.
下一步后一切正常。
- Set Dracula style for QtCreator :)
- Modify MSVS installation addning VC++ 2015.3 v140 toolset for desktop (x86,x64).
- 为 QtCreator 设置 Dracula 样式 :)
- 修改 MSVS 安装,添加 VC++ 2015.3 v140 桌面工具集 (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.
所以答案是尝试重新安装/修改组件,包括 QtCreator 本身。
回答by ScaledLizard
I had a similar case, which was solved by adding the path to cl.exe to the path environment variable:
我有一个类似的情况,通过将 cl.exe 的路径添加到路径环境变量中解决了这个问题:
set path=%path%;%qtdir%\bin;"C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Tools\MSVC.12.25827\bin\Hostx64\x64"
set QMakeSpec=win32-msvc
qmake -tp vc
Maybe another cl.exe is interfering here?
也许另一个 cl.exe 正在干扰这里?
回答by user
Just reboot. It helped me. Probably finalizes the installation of Visual Studio or Qt.
只需重新启动。它帮助了我。可能会完成 Visual Studio 或 Qt 的安装。