Unable to start debugging. Unexpected GDB output - c++

New to this stuff and vscode wont let me debug my C++ file. Whenever i hit F5, i get the following error:
Unable to start debugging. Unexpected GDB output from command "-environment-cd"d:\Users\MyName\\OneDrive\\Documentos\\My Projects"". d:\Users\MyName\OneDrive\Documentos\My Projects: No such file or directory
This is my launch.json file. Ive already tried this solution with no results.
{
// 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": "g++.exe - Compilar y depurar el archivo activo",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Strawberry\\c\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Habilitar la impresión con sangría para gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe compilar archivo activo"
}
]
}

Related

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 could I resolve missing or invalid .exe on debugger of VS Code?

I'm trying to debug my little program, but it's like it doesn't exist main.exe, but it exists.
My code is this simple:
And my launch.json is this one:
{
// 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": "cpp.exe - Compilar y depurar el archivo activo",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": true,
"cwd": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Habilitar la impresión con sangría para gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: cpp.exe build active file"
}
]
}
I don't know what it's wrong. Thank you.
My build output:
enter image description here
And my task.json is this one:
enter image description here

The preLaunch 'C/C++:gcc.exe build active file' terminated with exit code -1

When ever I debug my code in Visual Studio Code I get
The preLaunch 'C/C++:gcc.exe build active file' terminated with exit code -1
I built my file using cpp.exe,
here is the launch.json 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": "gcc.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "C://code//program.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file"
}
]
}

Build Project Without Debugging or Running in VS Code

I'm using Visual Studio Code to compile C and C ++ files but I just want to build the project without doing other actions, can that be in VS Code? Or will it always try to run the project? Here is my tasks.json 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": "vde.exe build",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "\\usr\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "vde.exe build active file"
}
]
}

VS code debugger doesn't open terminal

I'm trying to create a cpp environment on vs code. The build works, .exe gets generated, but the debugger doesn't seem to work. When I click on the run debug option, another terminal gets open with a message (attached in the screenshot). The code which I'm running is a simple hello world example. No terminal with Hello World is opened by the debugger. Hello world is supposed to be displayed in the screenshot of terminal 2 but another message gets printed, which I got no clue about.
Terminal 1
Terminal 2
This is the code for the config files:
task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"sample.cpp"
],
"problemMatcher": []
}
]
}
launch.json
{
// 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": "g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "C:\\Users\\Amey\\Desktop\\work\\Programming\\C++\\a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build"
}
]
}