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

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.

FYI, the CMake CMakeDetermineCompilerId.cmake logic for Visual Studio generator needs to successfully build a sample debug project to extract the CMAKE_<LANG>_COMPILER data from the build output. There is a post build step that echoes the compiler that is used to build the project.

In the CMakeError.log output you can see that the build failed because the ‘MSVCRTD.lib’ could not be found.

Indeed,
How do I make it find this file?
thanks

It’s part of the Windows SDK. Make sure you have it installed.

I have the following windows SDKs installed:

I have the following MSVCRTD.lib files on my machine: