# Visual Studio Compile errors

**URL:** https://discourse.cmake.org/t/visual-studio-compile-errors/2178
**Category:** Usage
**Created:** [November 14, 2020, 1:24pm UTC](https://discourse.cmake.org/t/visual-studio-compile-errors/2178 "2020-11-14T13:24:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![magicianyuan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/77aa72/32.png) [@magicianyuan](https://discourse.cmake.org/u/magicianyuan)
#### Post date: [November 14, 2020, 1:24pm UTC](https://discourse.cmake.org/t/visual-studio-compile-errors/2178/1 "2020-11-14T13:24:35Z")

</div>

There is an error happened while compiling my codes with CMAKE.By the way, i was working on windows system.  
The detail information is  
“Check for working CXX compiler: D:/mingw/bin/c++.exe --broken”  
This error has never happened before , but this week happened serval times.  
I can neithor figure out how to solve this nor why this error happens.  
T\_T

---

<div class="post-metadata">

### Author: ![McMartin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mcmartin/32/150_2.png) [@McMartin](https://discourse.cmake.org/u/McMartin)
#### Post date: [November 14, 2020, 9:23pm UTC](https://discourse.cmake.org/t/visual-studio-compile-errors/2178/2 "2020-11-14T21:23:23Z")

</div>

This is likely happening because you are using a generator which is not `Visual Studio <number> <year>` in an environment that doesn’t know about the toolchain of Visual Studio. To solve this, either:

- use a `Visual Studio <number> <year>` generator (for instance `Visual Studio 16 2019`), by passing the `-G` command line argument to `cmake`
- execute CMake in an environment that knows about the Visual Studio toolchain, for instance the “x64 Native Tools Command Prompt for VS 2019”

I hope this helps!

---

<div class="post-metadata">

### Author: ![magicianyuan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/77aa72/32.png) [@magicianyuan](https://discourse.cmake.org/u/magicianyuan)
#### Post date: [November 16, 2020, 1:57am UTC](https://discourse.cmake.org/t/visual-studio-compile-errors/2178/3 "2020-11-16T01:57:10Z")

</div>

Thanks a lot！I’d like to take the advise~
