"Property console is not allowed" Problem in VSC Ubuntu 20.04 - c++

I'm trying to debug my cpp program in Visual Studio Code in ubuntu 20.00. Hence,I'm facing to following problem:
{
"resource": "/home/xxx/Desktop/Project/.vscode/launch.json",
"owner": "_generated_diagnostic_collection_name_#4",
"severity": 4,
"message": "Property console is not allowed.",
"startLineNumber": 17,
"startColumn": 13,
"endLineNumber": 17,
"endColumn": 22
}
That's my launch.json file:
"version": "0.2.0",
"configurations": [
{
"name": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
I wonder how I handle this problem.
Thanks.

replace "console": "externalTerminal" with "externalTerminal" : true if you would like your code to execute in a external console window. Otherwise remove the line completly

Related

"program.exe doesn't exist" in VSCode when i try to use an external window

EDIT : the g++ is in my path, it isn't the problem.
I have been trying to use a launch.json to run my c++ programs in the external terminal, but every time it gives me an error program.exe doesn't exist although it works fine in the VS Code terminal.
Here is how the launch.json is configured:
{
"configurations": [
{
"name": "run and debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"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
}
]
}
]
}

Visual studio code with cmake on Windows, how to set compiler and debug configuration

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.

How to read input when debugging in C++ in Visual Studio Code without loosing encoding?

I want to debug a code that has std::cin on it.
If I put on launch.json '"externalConsole": false', I can't write anything (because there's no console to work on it).
However, If I put "externalConsole": true, my args of the shell are just ignored.
I'm using just IntelliSense.
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Criar e depurar o arquivo ativo",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Habilitar a reformatação automática para gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe arquivo de build ativo"
}
]
}
settings.json:
{
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.external.windowsExec": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"chcp 65001"
],
"workbench.colorTheme": "Visual Studio Dark - C++",
}
I need to use '"terminal.integrated.shellArgs.windows": ["/k", "chcp 65001"]' to use my encoding system.
Is there a way to work around this problem?

How to run D code program in visual studio? Ubuntu 18.04

Althougt I had installed dub,dmd. I can run test.d in terminal.But I can't run file test.d in visual studio code.
Maybe should change launch.son file?
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/mct.d",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Launch.json file
"program": "${workspaceRoot}/mct.d"
This should be a path to the executable, not the source file. Try:
"program": "${workspaceRoot}/mct.exe"

gdb on mojave works in terminal but not in vs code

After those tricks about codesigning, I've got to make gdb run on my mac (10.14.6), but only in terminal, and it gives no response in vs code.
Everything works just fine in terminal, like setting breakpoints, printing variables and running the executables, but it gets stuck in vs code, and nothing shows up in the variable and call stack sections.
Here's my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/local/bin/gdb",
/* "setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
], */
"preLaunchTask": "Build"
}
]
}
vs code
terminal