木口折 2024-01-18 12:07 采纳率: 50%
浏览 125
已结题

vs2022编译cmake项目时报错,显示找不到文件

vs2022编译cmake项目时报错,显示找不到文件。最开始时以为是安装目录存在空格导致的,重新安装并更改后确实成功编译文件。但半天后错误重新出现,之后重新安装vs并清空注册表能纠正错误,但错误依旧会在不定时间出现。请操作尽可能的详细或者远程协助。
错误截图

img


错误信息:
CMake Error at C:/vs/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler

"C:/vs/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: 'C:/Users/15294/source/repos/CMakeProject4/out/build/x64-debug/CMakeFiles/CMakeScratch/TryCompile-pwmpgl'

Run Build Command(s): c:\vs\common7\ide\commonextensions\microsoft\cmake\Ninja\ninja.exe -v cmTC_c31af
[1/2] C:\vs\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\cl.exe  /nologo   /DWIN32 /D_WINDOWS /W3  /MDd /Ob0 /Od /RTC1 -Zi /showIncludes /FoCMakeFiles\cmTC_c31af.dir\testCCompiler.c.obj /FdCMakeFiles\cmTC_c31af.dir\ /FS -c C:\Users\15294\source\repos\CMakeProject4\out\build\x64-debug\CMakeFiles\CMakeScratch\TryCompile-pwmpgl\testCCompiler.c
[2/2] cmd.exe /C "cd . && C:\vs\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_c31af.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\vs\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_c31af.dir\testCCompiler.c.obj  /out:cmTC_c31af.exe /implib:cmTC_c31af.lib /pdb:cmTC_c31af.pdb /version:0.0 /machine:x64  /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 ."
FAILED: cmTC_c31af.exe 
cmd.exe /C "cd . && C:\vs\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_c31af.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\vs\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_c31af.dir\testCCompiler.c.obj  /out:cmTC_c31af.exe /implib:cmTC_c31af.lib /pdb:cmTC_c31af.pdb /version:0.0 /machine:x64  /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_c31af.dir/manifest.res CMakeFiles\cmTC_c31af.dir/manifest.rc" failed (exit code 0) with the following output:
系统找不到指定的文件。
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project. C:/vs/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake 67

  • 写回答

17条回答 默认 最新

  • 急速光粒 2024-01-18 20:11
    关注

    问题是因为vs的vc目录下面缺少rc.exe和mt.exe,放入vc目录即可。经测试可用,问题彻底解决。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(16条)

报告相同问题?

问题事件

  • 系统已结题 1月27日
  • 已采纳回答 1月19日
  • 创建了问题 1月18日