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
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.
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.
In the cmake parlance, "generator" is an external program generating a build script.
In Linux, "generator" is usually make
or ninja
. In Windows you need a Windows-specific generator. The list of generators available for cmake
can be found in its documentation:
https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html
You need to install and configure at least one that runs on your OS. Remember: cmake
is NOT a generator - it uses a generator as an external tool, just like a compiler is an external tool. The compiler, generator, perhaps some other tools, plus an environment form what is called a (build) kit.
Since I don't use Windows, I can't help you in more detail, but you or anyone reading this answer will know what to do in your situation: use your WWW search engine to query for "Windows 10 Visual Studio Code cmake generator" or something similar. My first hit for Windows and VS Code is this:
https://computingonplains.wordpress.com/building-c-applications-with-cmake-and-visual-studio-code/
The crucial paragraph reads:
We first have to run CMake to create the build files. Click on the CMake: [Debug] button. The first time you do so, a list of build tool kits is displayed below the main menu. Select either Unspecified, or Visual Studio Build Tools 2019 Release - amd64. The No Kit Selected text in the status bar will change to [Visual Studio Build Tools 2019 Release - amd64], and a list of CMake configurations are displayed: Debug, Release, MinSizeRel, and RelWithDebInfo.
If there's no generator, eg Visual Studio Build Tools 2019 Release - amd64
to be selected, you need to install it.
Reinstalling cmake tools extension worked out for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.