Issue
I have Windows 7 with few different versions of Visual Studio and MinGW. When I create a cmake project and open it in Visual Studio Code it get configured automatically to use Visual Studio 14 compiler, I also have Visual Studio 17 and 19 installed, version 17 have "Desktop development with C++" workload.
installed.
I would like to know how to set which compiler to use when running initial configuration (when build folder is empty) and how to create a debug configuration. When I run plain debug button that do not require the configuration the break point do not trigger.
I have tried with these config files in launch.json
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"env": {
"Path": "${env:Path};D:\\Installation\\oracClient 19\\instantclient_19_14\\"
},
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "c:\\Users\\marko.grujic.CHIP\\.vscode\\extensions\\ms-vscode.cpptools-1.8.4\\debugAdapters\\bin\\WindowsDebugLauncher.exe",
"logging": {
"engineLogging": true
},
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"name": "(Windows) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"env": {
"Path": "${env:Path};D:\\Installation\\oracClient 19\\instantclient_19_14\\"
},
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"logging": {
"engineLogging": true
},
"console": "externalTerminal"
}
]
Non of these work, (gdb) Launch
config do not work because the code was compiled with Visual Studio compiler and I am trying to use MinGW debugger (This is assumption).
(Windows) Launch
also do not work but I have no idea why, it does run indefinitely but none of breakpoints work.
Solution
To change a compiler I recommend:
- deleting the build folder.
- From visual studio code press f1 and run:
CMake: scan for kits
. - f1 and run:
CMake: select a kit
.
On step number 3 you will be asked to select a compiler version.
Answered By - Tomislav Kordic Answer Checked By - Timothy Miller (WPSolving Admin)