cmake - 无法解决:“cl.exe”无法编译简单的测试程序
问题描述
我正在尝试从 ninja 构建 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
没有错误。
请让我知道是否有解决方案?先感谢您:)
解决方案
我按照以下步骤操作:
1) 检查 rc.exe 所在位置并将其路径添加到环境变量PATH
就我而言,它位于此处
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86
2) 在管理员模式下运行开发人员命令提示符。
推荐阅读
- java - 在 Selenium TestNG 中使用 Xl.generateReport 生成无效报告
- node.js - 控制器中的 SpyOn express 路由处理函数
- python - 如何根据 Y 轴值在绘图图表上填充颜色?
- sql - SELECT 语句作为 INSERT 参数以及其他参数
- python-3.x - 无法引用 xml 文件的元素
- android - 来自 Google Play 的通知 || 恶意行为或用户数据政策 || 意图重定向
- javascript - 找不到该类的标签
- hyperledger - 无法在 ubuntu 20.04 中安装 indy-sdk
- java - 使用 jcraft JSch 在 Java 中进行 SSH 密码身份验证失败并显示“Auth fail”,但命令行“ssh”有效
- html - 如何实现3行的DIV,顶行是固定大小的内容,中间行是可滚动的div,底行是状态栏