# No CMAKE\_C\_COMPILER could be found. No CMAKE\_CXX\_COMPILER could be found.

**URL:** https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948
**Category:** Usage
**Tags:** os:windows, lang:c
**Created:** [August 17, 2021, 5:58pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948 "2021-08-17T17:58:33Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![rco](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rco](https://discourse.cmake.org/u/rco)
#### Post date: [August 17, 2021, 5:58pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/1 "2021-08-17T17:58:33Z")

</div>

Hi,

Long story short, I’ve been struggling with a project in both VS2017 and VS2019, with both CMake 3.18 and CMake 3.21.1.

In VS2019, in the CMakeSettings.json file…

- If i set CMake generator to “Visual Studio 16 2019 Win64” CMake cache generation succeeds and i’m able to build and run.
- If i set CMake generator to “Visual Studio 15 2017 Win64” CMake cache generation fails:  
1\> CMake generation started for configuration: ‘x64-Debug’.  
1\> Command line: “C:\WINDOWS\system32\cmd.exe” /c “%SYSTEMROOT%\System32\[chcp.com](http://chcp.com) 65001 \>NUL && “c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\cmake\CMake\bin\cmake.exe” -G “Visual Studio 15 2017” -A x64 -DCMAKE\_CONFIGURATION\_TYPES:STRING=“Debug” -DCMAKE\_INSTALL\_PREFIX:PATH=“D:\s\CMakeBuilds\f1e0f0a6-b40c-47b9-ac01-10c27884e354\install\x64-Debug” “D:\s” 2\>&1”  
1\> Working directory: D:\s\CMakeBuilds\f1e0f0a6-b40c-47b9-ac01-10c27884e354\build\x64-Debug  
1\> [CMake] CMakeLists debug 1  
1\> [CMake] – Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.  
1\> [CMake] – The C compiler identification is unknown  
1\> [CMake] – The CXX compiler identification is unknown  
1\> [CMake] CMake Error at D:\s\CMakeLists.txt:7 (project):  
1\> [CMake] No CMAKE\_C\_COMPILER could be found.  
1\> [CMake]  
1\> [CMake]  
1\> [CMake]  
1\> [CMake] CMake Error at D:\s\CMakeLists.txt:7 (project):  
1\> [CMake] No CMAKE\_CXX\_COMPILER could be found.

Why can’t it find these compilers?  
Thanks.

---

<div class="post-metadata">

### Author: ![rco](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rco](https://discourse.cmake.org/u/rco)
#### Post date: [August 31, 2021, 6:13am UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/2 "2021-08-31T06:13:46Z")

</div>

this. is. killing. me.

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [August 31, 2021, 2:50pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/3 "2021-08-31T14:50:12Z")

</div>

Since you are using CMakeSettings.json it’s hard to answer your question, without even knowing what your json looks like.

Also it’s worth considering replacing your usage of CMakeSettings.json with CMakePresets.json

- CMakeSettings.json is Visual Studio exclusive, and was basically a stop gap until CMakePresets.json was introduced in 3.19

---

<div class="post-metadata">

### Author: ![rco](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rco](https://discourse.cmake.org/u/rco)
#### Post date: [August 31, 2021, 5:33pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/4 "2021-08-31T17:33:55Z")

</div>

Hi, thanks for the reply!

Here’s the contents of my CMakeSettings.json file:  
**{  
“configurations”: [  
{  
“name”: “win64-Debug”,  
“generator”: “Visual Studio 15 2017 Win64”,  
“configurationType”: “Debug”,  
“inheritEnvironments”: [“msvc\_x64\_x64”],  
“buildRoot”: “${projectDir}\CMakeBuilds\${workspaceHash}\build\${name}”,  
“installRoot”: “${projectDir}\CMakeBuilds\${workspaceHash}\install\${name}”,  
“cmakeCommandArgs”: “”,  
“buildCommandArgs”: “-m -v:minimal”,  
“ctestCommandArgs”: “”  
}  
]  
}**

I have tried using the CMakePresets.json method, the reason I went back to CMakeSettings.json was because it defaulted to the _ninja_ generator, which has never worked for me. There doesn’t seem to be an editor built into VS for CMakePresets.json like there is for CMakeSettings.json. I could give it another try though. I haven’t seen what/if the advantages of CMakePresets over CMakeSettings.

Thanks again buildSystemPerson.

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [September 1, 2021, 2:44pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/5 "2021-09-01T14:44:01Z")

</div>

Let’s forget about CMakeSettings.json for a second.

Can you build a VS 2019/2017 project with CMake standalone?

```auto
cd foobar/
cmake -B build/vs2019 -G "Visual Studio 16 2019"
cmake -B build/vs2017 -G "Visual Studio 15 2017"

```

If this doesn’t work it means you don’t have the necessary software installed on your system. You’ll need to look at your VS installations.

If that doesn’t work consider refreshing your installations:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/b/b0910801f5e8c9e66d3ac36108c87fe0fd46c7cb.png)

Also I understand this is frustrating. It’s just how Microsoft decided to make their C++ build environment. They decided to tie their compiler to their IDE. That approach has trade offs.

At our company we actually don’t even rely on VS for our drivers to compile using MSVC. Since it’s a pain to ensure developers use the same compiler. We actually run our own packaging system around MSVC to ensure we have easily reproducible builds with strict semantic versioning control. This means extra work to understand the MSVC C++ environment, but it also means we don’t have to worry about updating Visual Studio breaking developer builds. Or dev A uses a slightly different compiler then dev B. Or devs using a different compiler than our CI.

---

<div class="post-metadata">

### Author: ![fdk17](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/ea666f/32.png) [@fdk17](https://discourse.cmake.org/u/fdk17)
#### Post date: [September 1, 2021, 3:12pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/6 "2021-09-01T15:12:28Z")

</div>

Did you install Visual Studio 15 2017?  
It’s sound like what you really want is to use Visual Studio 16 2019 IDE but with the 2017 toolset. I’m pretty sure you’d want to use the -T option.

---

<div class="post-metadata">

### Author: ![alvaropalmaaste](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alvaropalmaaste/32/1740_2.png) [@alvaropalmaaste](https://discourse.cmake.org/u/alvaropalmaaste)
#### Post date: [September 1, 2021, 4:10pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/7 "2021-09-01T16:10:43Z")

</div>

If I remember correctly, there was a subtle change in the generator from Visual Studio 2017 to 2019:

- 2017: `-G "Visual Studio 15 2017 Win64"` (NOT `-G "Visual Studio 15 2017" -A x64`)

- 2019: `-G "Visual Studio 16 2019" -A x64`

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [September 2, 2021, 10:21am UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/8 "2021-09-02T10:21:41Z")

</div>

@alvaropalmaaste according to the docs it’s fine to use -A with VS2017:

```auto
The CMAKE_GENERATOR_PLATFORM variable may be set, perhaps via the cmake(1) -A option, to specify a target platform name (architecture). For example:

    cmake -G "Visual Studio 15 2017" -A Win32

    cmake -G "Visual Studio 15 2017" -A x64

    cmake -G "Visual Studio 15 2017" -A ARM

    cmake -G "Visual Studio 15 2017" -A ARM64

For compatibility with CMake versions prior to 3.1, one may specify a target platform name optionally at the end of the generator name. This is supported only for:

Visual Studio 15 2017 Win64

    Specify target platform x64.
Visual Studio 15 2017 ARM

    Specify target platform ARM.

```

---

<div class="post-metadata">

### Author: ![rco](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rco](https://discourse.cmake.org/u/rco)
#### Post date: [September 7, 2021, 4:43pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/9 "2021-09-07T16:43:59Z")

</div>

Hi buildSystemPerson,

**I get the same result on the commandline as I do in VS…**  
C:\Program Files\CMake\bin\>cmake -S D:\s -B D:\s\build\vs2017 -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/vs2017/CMakeFiles/CMakeOutput.log”.  
See also “D:/s/build/vs2017/CMakeFiles/CMakeError.log”.

**The beginning contents of CMakeError.log:**  
Compiling the C compiler identification source file “CMakeCCompilerId.c” failed.  
Compiler:  
Build flags:  
Id flags:

The output was:  
1  
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework  
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 9/7/2021 12:29:58 PM.  
Project “D:\s\build\vs2017\CMakeFiles\3.21.1\CompilerIdC\CompilerIdC.vcxproj” on node 1 (default targets).  
PrepareForBuild:  
Creating directory “Debug”.  
Creating directory “Debug\CompilerIdC.tlog”.  
InitializeBuildStatus:  
Creating “Debug\CompilerIdC.tlog\unsuccessfulbuild” because “AlwaysCreate” was specified.  
ClCompile:  
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\CL.exe /c /nologo /W0 /WX- /diagnostics:classic /Od /Oy- /D \_MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar\_t /Zc:forScope /Zc:inline /Fo"Debug\" /Fd"Debug\vc141.pdb" /Gd /TC /analyze- /FC /errorReport:queue CMakeCCompilerId.c  
CMakeCCompilerId.c  
Link:  
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:“level=‘asInvoker’ uiAccess=‘false’” /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X86 /SAFESEH Debug\CMakeCCompilerId.obj  
LINK : fatal error LNK1104: cannot open file ‘MSVCRTD.lib’ [D:\s\build\vs2017\CMakeFiles\3.21.1\CompilerIdC\CompilerIdC.vcxproj]  
Done Building Project “D:\s\build\vs2017\CMakeFiles\3.21.1\CompilerIdC\CompilerIdC.vcxproj” (default targets) – FAILED.

Build FAILED.

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [September 7, 2021, 4:57pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/10 "2021-09-07T16:57:18Z")

</div>

Do you have all the relevant VS 2017 software installed on your machine?

---

<div class="post-metadata">

### Author: ![rco](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rco](https://discourse.cmake.org/u/rco)
#### Post date: [September 7, 2021, 5:12pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/11 "2021-09-07T17:12:34Z")

</div>

I’ve been assuming not since the beginning, but I don’t know for certain what is needed…

 ![image](https://discourse.cmake.org/uploads/default/original/2X/8/8b29eef55104d70bba8da3e4ce846d34d0de7c02.png)

---

<div class="post-metadata">

### Author: ![rco](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rco](https://discourse.cmake.org/u/rco)
#### Post date: [September 7, 2021, 5:13pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/12 "2021-09-07T17:13:06Z")

</div>

![image](https://discourse.cmake.org/uploads/default/original/2X/c/cc4f32d3067679f34dbf4142aa687745821f06c3.png)

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [September 7, 2021, 6:51pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/13 "2021-09-07T18:51:17Z")

</div>

Could you go into the modify section for VS 2017? We need to know the specific components you installed. Just having the IDE doesn’t show anything. For example here is my local VS 2019:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/f/f78fee698cf2d0691f575755b488cc2a2cafe06b.png)

You need the compiler (MSVC) and a version of the SDK, and you most likely a debugger/profiler. Not sure if those last 2 are needed for CMake.

---

<div class="post-metadata">

### Author: ![rco](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rco](https://discourse.cmake.org/u/rco)
#### Post date: [September 7, 2021, 6:58pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/14 "2021-09-07T18:58:04Z")

</div>

Here’s what I have:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/f/fd17ccd2f89c54586da0c0c20de0ef394701c666.png)

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [September 7, 2021, 7:32pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/15 "2021-09-07T19:32:09Z")

</div>

I’m honestly stuck… it looks like you have the right things for VS 2017.

Although I have never personally used CMake with 2 versions of Visual Studio on my computer.

Maybe consider repairing your Visual Studio installation? One time a coworker of mine was having an issue with CMake / Visual Studio and this fixed it.

> **[Repair Visual Studio](https://docs.microsoft.com/en-us/visualstudio/install/repair-visual-studio?view=vs-2019)**
>
> Learn how to repair an installation of Visual Studio 2017

---

<div class="post-metadata">

### Author: ![fdk17](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/ea666f/32.png) [@fdk17](https://discourse.cmake.org/u/fdk17)
#### Post date: [September 7, 2021, 7:36pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/16 "2021-09-07T19:36:29Z")

</div>

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

> <https://stackoverflow.com/questions/55230514/after-installing-wdk-vc-is-broken>

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [September 8, 2021, 12:40pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/17 "2021-09-08T12:40:15Z")

</div>

Looks like someone is having a similar issue here:

> [@Windows configure error when using the command line: "The C/CXX compiler identification is unknown.."](https://discourse.cmake.org/t/windows-configure-error-when-using-the-command-line-the-c-cxx-compiler-identification-is-unknown/4053/2):
>
> Guessing: The cmake-gui chooses the 32bit (host and target) version of the compiler. You choose the host=64bit version with CLI

---

<div class="post-metadata">

### Author: ![rco](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rco](https://discourse.cmake.org/u/rco)
#### Post date: [September 8, 2021, 6:55pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/18 "2021-09-08T18:55:07Z")

</div>

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”.

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [September 8, 2021, 7:53pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/19 "2021-09-08T19:53:44Z")

</div>

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.

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

```

---

<div class="post-metadata">

### Author: ![rco](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rco](https://discourse.cmake.org/u/rco)
#### Post date: [September 8, 2021, 8:02pm UTC](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948/20 "2021-09-08T20:02:43Z")

</div>

**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”.

[Next page](https://discourse.cmake.org/t/no-cmake-c-compiler-could-be-found-no-cmake-cxx-compiler-could-be-found/3948.md?page=2)
