No CMAKE_C_COMPILER could be found. No CMAKE_CXX_COMPILER could be found.

I’ve read that installing the WDK can cause problems.

1 Like

Looks like someone is having a similar issue here:

I repaired my VS2017, rebooted, and same result.

Not sure what the host is, but I tried these:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cmake -S D:\s -B D:\s\build\vs2017 -G “Visual Studio 15 2017” -A x64 -T host=x64
CMakeLists debug 11
– Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
– The C compiler identification is unknown
– The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:7 (project):
No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:7 (project):
No CMAKE_CXX_COMPILER could be found.

– Configuring incomplete, errors occurred!
See also “D:/s/build/vs2017/CMakeFiles/CMakeOutput.log”.
See also “D:/s/build/vs2017/CMakeFiles/CMakeError.log”.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cmake -S D:\s -B D:\s\build\vs2017 -G “Visual Studio 15 2017” -A x64 -T host=x86
CMakeLists debug 11
– Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
– The C compiler identification is unknown
– The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:7 (project):
No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:7 (project):
No CMAKE_CXX_COMPILER could be found.

– Configuring incomplete, errors occurred!
See also “D:/s/build/vs2017/CMakeFiles/CMakeOutput.log”.
See also “D:/s/build/vs2017/CMakeFiles/CMakeError.log”.

Lets reduce the variables by not explicitly using -A or -T

And lets cd into the proper directory. Also lets delete any possible build artifacts I can’t see on your machine.

cd D:/s
rm build/ -recurse -force
cmake -B build/ -G “Visual Studio 15 2017”

Same issue:

D:\s>cmake -B build/ -G “Visual Studio 15 2017”
CMakeLists debug 11
– Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
– The C compiler identification is unknown
– The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:7 (project):
No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:7 (project):
No CMAKE_CXX_COMPILER could be found.

– Configuring incomplete, errors occurred!
See also “D:/s/build/CMakeFiles/CMakeOutput.log”.
See also “D:/s/build/CMakeFiles/CMakeError.log”.

Could you try launching this via cmake-gui? I’d like to see if you are having a similar issue like this discourse is showing

cd D:/s
rm build/ -recurse -force
cmake-gui -S . -B build/

Also have you checked this stackoverflow before?

Here is another similar link I found with a similar question to yours.

Not sure how to enter those commands in the GUI…
It did seem to work for the first time in the GUI however.
I configured it like so:
image

Then hit Generate:

I’m currently looking into this error in the CMakeError.log file:
Determining if the include file pthread.h exists failed with the following output:
Change Dir: D:/s/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe cmTC_18586.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=15.0 /v:m && Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27045 for x64

Copyright (C) Microsoft Corporation. All rights reserved.

cl /c /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D “CMAKE_INTDIR=“Debug”” /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_18586.dir\Debug\" /Fd"cmTC_18586.dir\Debug\vc141.pdb" /Gd /TC /errorReport:queue D:\s\build\CMakeFiles\CMakeTmp\CheckIncludeFile.c

CheckIncludeFile.c

D:\s\build\CMakeFiles\CMakeTmp\CheckIncludeFile.c(1): fatal error C1083: Cannot open include file: ‘pthread.h’: No such file or directory [D:\s\build\CMakeFiles\CMakeTmp\cmTC_18586.vcxproj]

In my case, whatever the option is empty or x64, the cmake-gui configuration were successful, but the CLI fails.
image

I’d have to start looking into the CMake code at this point to find out why it’s unable to find visual studio in your terminal environments. But not via cmake-gui.

Perhaps you are setting something in your PATH or general environment variables that is confusing CMake?

That’s speculation at this point though. I’d have to look at the CMake source code.

Here’s my path environment variable:

In your powershell try minimizing your PATH like this:

That way you will have the bare minimum amount of stuff in your path.

Then try running the cmake command for vs 2017 like before.

That seems to work:

So I guess my path is too long?
(it is 1809 characters, it’s been a while since i’ve run into this problem, let me do some research)

1 Like

Nice! I’m glad I was able to help!

Most likely something inside your PATH is confusing CMake somehow. @ben.boeckel do you have any guesses as to what’s happening?

It’s too hard to tell without the setup. I’d recommend strace to see, but Process Monitor is the best I know of on Windows. Other than that…don’t mess with the system path too much (in general) :slight_smile: .

1 Like

Make sure to mark your question as answered btw @rco

I need it to work in visual studio, which it still doesn’t.
I’ve moved the “C:\Program Files\CMake\bin” to the top of the list, and i’m able to build on the command line with this reordered 1809 character path, but I still get the same error in visual studio.

I started using the process monitor, still exploring that.