CMake: "The C compiler is not able to compile a simple test program"

Angel 0 Reputation points
2023-09-24T21:50:00.7833333+00:00

It wasn't an issue in the past but if I try to build a current or create a new cmake project right now with visual studio and use Ninja as my generator it fails with "The C compiler "../cl.exe" is not able to compile a simple test program" and has the bellow output (which doesn't seem to provide any useful information).

Change Dir: C:/Users/aggelos/Documents/Visual Studio 2022/Projects/mycmake/out/CMakeFiles/CMakeScratch/TryCompile-svcz3s      

Run Build Command(s):C:/PROGRA~1/MICROS~4/2022/COMMUN~1/Common7/IDE/COMMON~1/MICROS~1/CMake/Ninja/ninja.exe -v cmTC_37dfe && [1/2] C:\PROGRA~1\MICROS~4\2022\COMMUN~1\VC\Tools\MSVC\1437~1.328\bin\Hostx86\x86\cl.exe  /nologo   /DWIN32 /D_WINDOWS /W3  /MDd /Ob0 /Od /RTC1 -Zi /showIncludes /FoCMakeFiles\cmTC_37dfe.dir\testCCompiler.c.obj /FdCMakeFiles\cmTC_37dfe.dir\ /FS -c "C:\Users\aggelos\Documents\Visual Studio 2022\Projects\mycmake\out\CMakeFiles\CMakeScratch\TryCompile-svcz3s\testCCompiler.c"     
[2/2] cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_37dfe.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\mt.exe --manifests  -- C:\PROGRA~1\MICROS~4\2022\COMMUN~1\VC\Tools\MSVC\1437~1.328\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_37dfe.dir\testCCompiler.c.obj  /out:cmTC_37dfe.exe /implib:cmTC_37dfe.lib /pdb:cmTC_37dfe.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 ."     
FAILED: cmTC_37dfe.exe     
cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_37dfe.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\mt.exe --manifests  -- C:\PROGRA~1\MICROS~4\2022\COMMUN~1\VC\Tools\MSVC\1437~1.328\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_37dfe.dir\testCCompiler.c.obj  /out:cmTC_37dfe.exe /implib:cmTC_37dfe.lib /pdb:cmTC_37dfe.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 ."     
ninja: build stopped: subcommand failed.
Developer technologies | Visual Studio | Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.