windows - Qt Creator由于错误的link.exe路径而无法打开CMake项目

标签 windows visual-studio cmake visual-studio-2017 qt-creator

我最近升级了Visual Studio 2017,现在无法在Qt Creator 4.8.2中打开CMake项目。

cmd.exe运行时,CMake成功测试了编译器,但在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?

我尝试在my Qt Creator Compiler options中找到相应的选项,但是它声称使用了在命令行上运行良好的相同vcvarsall.bat调用...
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中,因为the answer to a similar question建议
  • 在同一窗口中运行cmd.exe后,从vcvarsall.bat启动Qt Creator
  • 将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菜单中。

    关于windows - Qt Creator由于错误的link.exe路径而无法打开CMake项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55453506/

    相关文章:

    android - 尝试让 USB 调试在 Windows 7 (Android) 上工作时出现问题

    html - 文本定位在 MAC 和 Windows 上的行为不同

    c - 内核驱动程序: How get correct content of each variable in a struct?

    CMake:我如何依赖自定义目标的输出?

    opencv - 使用 CMake 问题构建 OpenCV

    windows - 使用 UIElement 创建 Cordova UWP 插件

    windows - 使用 mingw_64 在 Windows 上编译 Rust 时无法加载代码生成后端

    带有 ostream 运算符的 C++ 类可与 VS 一起使用,但无法使用 gcc 进行编译

    visual-studio - Visual Studio 2022 无法添加服务引用且没有程序集引用节点

    cmake - 制作 .deb 包时如何找出最低要求?