0

When I open CMake in Visual Studio 2022 , I got this error:

CMake Error at C: /VisualStudio/Common7 / IDE / CommonExtensions / Microsoft / CMake / CMake / share / cmake - 3.25 / Modules / CMakeTestCCompiler.cmake: 70(message): The C compiler "C:/VisualStudio/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output: Change Dir: C: /VisualStudio/Common7 / IDE / CommonExtensions / Microsoft / CMake / CMake / bin / CMakeProject1 / out / build / x64 - debug / CMakeFiles / CMakeScratch / TryCompile - ytu82w
Run Build Command(s): C: \VISUALSTUDIO\ COMMON7\ IDE\ COMMONEXTENSIONS\ Microsoft\ CMake\ Ninja\ ninja.exe cmTC_d465b && [1 / 2] Building C object CMakeFiles\ cmTC_d465b.dir\ testCCompiler.c.obj[2 / 2] Linking C executable cmTC_d465b.exe
FAILED: cmTC_d465b.exe
cmd.exe / C "cd . && C:\VisualStudio\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_d465b.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\VisualStudio\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_d465b.dir\testCCompiler.c.obj  /out:cmTC_d465b.exe /implib:cmTC_d465b.lib /pdb:cmTC_d465b.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_d465b.dir/manifest.res CMakeFiles\cmTC_d465b.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.

I followed the instructions here :

Visual Studio can't build due to rc.exe :

This is what I did :

  1. I run this command line from 2022 Visual Studio developer command line : vcvarsall.bat x64 8.1

and the environmment was successfully initialized for Visual Studio

  1. I copied the windows kits rc.exe and rcdll.dll to Visual Studio 2022 binary directory which is :

C:\VisualStudio\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64

  1. I set Windows Kits SDK path C:\Program Files (x86)\Windows Kits\8.1\bin\x64 to windows 10 environment variables . Then I opened Visual Studio 2022 and create a new CMake project but I now got another error :

    The C compiler "C:/VisualStudio/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: C: /VisualStudio/Common7 / IDE / CommonExtensions / Microsoft / CMake / CMake / bin / CMakeProject1 / out / build / x64 - debug / CMakeFiles / CMakeScratch / TryCompile - j9msba Run Build Command(s): C: \VISUALSTUDIO\ COMMON7\ IDE\ COMMONEXTENSIONS\ MICROSOFT\ CMAKE\ Ninja\ ninja.exe cmTC_11ce3 && [1 / 2] Building C object CMakeFiles\ cmTC_11ce3.dir\ testCCompiler.c.obj[2 / 2] Linking C executable cmTC_11ce3.exe FAILED: cmTC_11ce3.exe cmd.exe / C "cd . && C:\VisualStudio\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_11ce3.dir --rc=C:\VisualStudio\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\8.1\bin\x64\mt.exe --manifests -- C:\VisualStudio\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_11ce3.dir\testCCompiler.c.obj /out:cmTC_11ce3.exe /implib:cmTC_11ce3.lib /pdb:cmTC_11ce3.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 ." LINK Pass 1: command "C:\VisualStudio\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_11ce3.dir\testCCompiler.c.obj /out:cmTC_11ce3.exe /implib:cmTC_11ce3.lib /pdb:cmTC_11ce3.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 /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_11ce3.dir/intermediate.manifest CMakeFiles\cmTC_11ce3.dir/manifest.res" failed(exit code 1104) with the following output: LINK: fatal error LNK1104: cannot open file 'kernel32.lib' ninja: build stopped: subcommand failed. CMake will not be able to correctly generate this project.

james
  • 131
  • 5
  • The error message `The system cannot find the file specified` is about `rc` executable. See e.g. [that question](https://stackoverflow.com/questions/14372706/visual-studio-cant-build-due-to-rc-exe). – Tsyvarev May 17 '23 at 07:32

0 Answers0