windows - Qt Creator 因 link.exe 路径错误而无法打开 CMake 项目
问题描述
我最近升级了 Visual Studio 2017,现在无法在 Qt Creator 4.8.2 中打开 CMake 项目。
CMake 在运行时成功测试编译器,cmd.exe
但在 Qt Creator 中失败:
Running "C:\Program Files\CMake\bin\cmake.exe -E server "--pipe=\\.\pipe\{b2399ce2-b8c1-4992-94b7-57b65efed70f}" --experimental" in D:\checkout\mateju\integrace\util\itex\build_Qt5-Release.
Starting to parse CMake project.
The C compiler identification is MSVC 19.16.27027.1
The CXX compiler identification is MSVC 19.16.27027.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/Program Files (x86)/Microsoft Visual
Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe" is
not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/checkout/mateju/integrace/util/itex/build_Qt5-Release/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_1344c\fast"
"C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"
-f CMakeFiles\cmTC_1344c.dir\build.make /nologo -L
CMakeFiles\cmTC_1344c.dir\build
Building C object CMakeFiles/cmTC_1344c.dir/testCCompiler.c.obj
C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe
@C:\Users\MATEJU~1\AppData\Local\Temp\nmEB0D.tmp
testCCompiler.c
Linking C executable cmTC_1344c.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe
--intdir=CMakeFiles\cmTC_1344c.dir --manifests -- "C:\Program Files
(x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\link.exe"
/nologo @CMakeFiles\cmTC_1344c.dir\objects1.rsp
@C:\Users\MATEJU~1\AppData\Local\Temp\nmEC75.tmp
LINK Pass 1 failed to run.
NMAKE : fatal error U1077: "C:\Program Files\CMake\bin\cmake.exe":
return code 0xffffffff
Stop.
NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe":
return code 0x2
Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
Configuring incomplete, errors occurred!
See also "D:/checkout/mateju/integrace/util/itex/build_Qt5-Release/CMakeFiles/CMakeOutput.log".
See also "D:/checkout/mateju/integrace/util/itex/build_Qt5-Release/CMakeFiles/CMakeError.log".
CMake Project parsing failed.
如您所见,编译器路径为:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64
但是,它正在路径中寻找链接器:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64
所以我的问题是:如何将链接器路径更新到(唯一存在的)14.16.27023?或者我还应该怎么做才能继续在 Qt Creator 中使用 CMake?
我试图在我的 Qt Creator 编译器选项中找到相应的选项,但它声称使用vcvarsall.bat
在命令行上运行良好的相同调用......</p>
D:\build>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.8
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
D:\build>link
Microsoft (R) Incremental Linker Version 14.16.27027.1
Copyright (C) Microsoft Corporation. All rights reserved.
<and so on...>
我尝试了以下步骤但没有成功:
- 添加
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64
到PATH
类似问题的答案所暗示的 - 在同一窗口中
cmd.exe
运行后启动 Qt Creatorvcvarsall.bat
- 将 CMake 升级到最新的稳定版本 (3.14.1)
- 在 Qt Creator 4.9.0-rc1 中安装并试用
- 搜索字符串
14.10.25017
- 在 Windows 注册表中 - 没有结果
- 在 Qt Creator 目录中
- 找不到配置文件
- 找到
.pdb
和.lib
文件,这可能仅意味着它们是使用此版本的 Visual Studio 构建的
- 在
C:\Program Files (x86)\Microsoft Visual Studio
- 没有结果 - 在
C:\Program Files (x86)\Windows Kits
- 没有结果
解决方案
经过问题中提到的几次不成功的猜测,我发出后成功打开,构建和运行我的项目
构建 > 清除 CMake 配置
在 Qt Creator 的菜单中。
推荐阅读
- c# - 按类别的行的混乱分布
- r - 是否有可能使用 grid.arrange 放置地块编号/字母?
- android - 安卓壁纸服务
- c - Xcode和Visual Studio中的OpenGL结果差异
- sql-server - 更新和限制的语法不正确
- r - 将多个图与牛图对齐
- php - 获取记录时出现mysql错误
- php - Docker和php“standard_init_linux.go:207:exec用户进程导致“exec格式错误”。入口点也无法读取exec的参数
- c++ - 绘制函数中的 QStyledItemDelegate 问题
- c - string.h的strcmp和我自己实现的strcmp的区别