cmake - 无法解析 : "cl.exe" is not able to compile a simple test program

标签 cmake llvm

我正在尝试从忍者构建 llvm 源代码。

我正在关注 http://clang.llvm.org/docs/LibASTMatchersTutorial.html 指南。

当我尝试在开发人员命令提示符下运行命令时 cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"-DLLVM_BUILD_TESTS=ON

这是抛出错误

-- The C compiler identification is MSVC 19.16.27032.1
-- The CXX compiler identification is MSVC 19.16.27032.1
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- broken
CMake Error at C:/Users/Desktop/clang-llvm/cmake/cmake-3.15.1-win64-x64/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/Desktop/clang-llvm/build/CMakeFiles/CMakeTmp

    Run Build Command(s):C:/Users/Desktop/clang-llvm/ninja/ninja.exe cmTC_2dc03 && [1/2] Building C object CMakeFiles\cmTC_2dc03.dir\testCCompiler.c.obj
    [2/2] Linking C executable cmTC_2dc03.exe
    FAILED: cmTC_2dc03.exe
    cmd.exe /C "cd . && C:\Users\Desktop\clang-llvm\cmake\cmake-3.15.1-win64-x64\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_2dc03.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~2\MIB055~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_2dc03.dir\testCCompiler.c.obj  /out:cmTC_2dc03.exe /implib:cmTC_2dc03.lib /pdb:cmTC_2dc03.pdb /version:0.0  /machine:X86  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
    RC Pass 1: command "rc /fo CMakeFiles\cmTC_2dc03.dir/manifest.res CMakeFiles\cmTC_2dc03.dir/manifest.rc" failed (exit code 0) with the following output:
    The system cannot find the file specified
    ninja: build stopped: subcommand failed.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:49 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/Desktop/clang-llvm/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Desktop/clang-llvm/build/CMakeFiles/CMakeError.log".


我试着运行一个程序 C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe 没有错误。

请问有解决办法吗?提前谢谢你:)

最佳答案

我遇到了类似的情况,并且能够通过在“Visual Studio 安装程序”中安装另一个 Windows SDK 来修复它。

我刚刚取消选择当前选中的“Windows SDK 10”并选择最新的“Windows 11 SDK”,一切都像以前一样正常。

另见 Linker Tools Error LNK1104 - Microsoft Docs .

但是,我不知道这些背后的原因。如果我没记错的话,几天前我刚刚通过 Visual Studio 安装程序更新了 Visual Studio。

关于cmake - 无法解析 : "cl.exe" is not able to compile a simple test program,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57269635/

相关文章:

c++ - CMake:Eigen3 包含第三个项目所需的目录

c++ - 将 libc++ 链接到 Linux 上的 CMake 项目

Windows:Boost 和 CMake

llvm - 通过LLVM API直接生成机器代码

c++ - Cygwin 的 cmake 与 CMAKE_SYSTEM_NAME 不匹配

windows - CMake 在 Windows 上找不到库

compiler-construction - 如何在 libclang 中刷新 AST

architecture - 如何在 clang 中列出支持的目标架构?

c++ - 如何使用 clang++ 进行编译?

llvm - 如何使用 Debug模式在 LLVM 中编译某些模块,而其他模块则使用 Release模式?