Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to determine what cmake generator to use-VS Code-Windows 10

Tags:

c++

c++17

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

like image 715
anjaly Avatar asked Dec 31 '25 05:12

anjaly


2 Answers

Firstly check the system.

  1. Install MINGW https://www.msys2.org/

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

  3. Check installation:

    gcc --version

    g++ --version

    gdb --version

  4. Edit environment variables for your account (PATH)

    C:\msys64\mingw64\bin

For cmake project on Vscode:

  1. Create a cmake project: https://code.visualstudio.com/docs/cpp/cmake-linux#_create-a-cmake-project

  2. Choose the Kit (Toolchain) which was installed before

  3. Set cmake.cmakePath (If you installed with pacman, the path should be same as gcc/g++.

    "cmake.cmakePath": "C:\msys64\mingw64\bin\cmake.exe"

  4. Reset VScode: Ctrl+shift+P and type "CMake:Reset CMake Tools for Extension State"

  5. Configure project: Ctrl+shift+P and type "CMake: Configure". You will see "built" directory and generated files.

like image 113
gkhanacer Avatar answered Jan 01 '26 18:01

gkhanacer


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.

like image 26
Luis Díaz Avatar answered Jan 01 '26 19:01

Luis Díaz