while compiling cpp files in vs code in windows 10 PC, after giving "cmake:debug" I get error like this "unable to determine what cmake generator to use.please install or configure a preferred generator or update settings.json, your kit configuration or path variable" how to solve the error
-
Did you install cmake and set it up in your project? – bolov Dec 02 '21 at 11:19
-
I installed cmake and also added it's path to system environment variable. – anjaly Dec 03 '21 at 04:00
-
Any luck with this issue? Were you able to solve the problem? – user541396 Mar 13 '22 at 17:53
-
For correct cmake generation of mingw I use ninja. You should add ninja path to system environment variable or just to copy ninja.exe to bin folder witch you already added or install it with help pacman. – igor Mar 29 '22 at 09:50
-
Use the `Ninja` generator whenever you can. `Ninja` is significantly faster than any of the other options and it's trivial to install and use. – Jesper Juhl Jul 17 '23 at 17:09
2 Answers
Firstly check the system.
Install MINGW https://www.msys2.org/
Install gcc, g++, gdb, and cmake using pacman.
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-gdb
pacman -S mingw-w64-x86_64-cmake
Check installation:
gcc --version
g++ --version
gdb --version
Edit environment variables for your account (PATH)
C:\msys64\mingw64\bin
For cmake project on Vscode:
Create a cmake project: https://code.visualstudio.com/docs/cpp/cmake-linux#_create-a-cmake-project
Choose the Kit (Toolchain) which was installed before
Set cmake.cmakePath (If you installed with pacman, the path should be same as gcc/g++.
"cmake.cmakePath": "C:\msys64\mingw64\bin\cmake.exe"
Reset VScode: Ctrl+shift+P and type "CMake:Reset CMake Tools for Extension State"
Configure project: Ctrl+shift+P and type "CMake: Configure". You will see "built" directory and generated files.

- 575
- 7
- 25
-
1Very good and quick guide. I think it should be in official vscode docs :) – pktiuk Oct 29 '22 at 12:36
-
I found that I also needed to select "let cmake choose which kits to use" after running reset. If you choose the VS Code selected one it still remains broken. – pups Jul 17 '23 at 17:04
If you have install cmake, setted up your project and you added it's path, try this Ctrl+shift+P and Type "cmake:reset cmake tools for extension state" and press enter.
At least that works for me.

- 61
- 1
- 3