anjaly
anjaly

Reputation: 161

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

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

Upvotes: 15

Views: 49158

Answers (2)

gkhanacer
gkhanacer

Reputation: 739

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.

Upvotes: 18

Luis Díaz
Luis Díaz

Reputation: 61

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.

Upvotes: 6

Related Questions