#Setting up Debugger for C in Visual Studio Code

13 messages · Page 1 of 1 (latest)

left snow
#

I set up GCC for C with this video.
https://www.youtube.com/watch?v=k6juv3mIr9o

I've downlaoded the c/c++ extension from visual studio.

yet when I press f5 to debug, I get this message. (screenshot)

I asked claude to help me fix this. we updated settings.json and tasks.json, and now I'm receiving this error when I press f5: "Configuration 'C/C++: gcc.exe build and debug active file' is missing in 'launch.json'."

some additional context: I've ran into the screenshot error 3x already today; each time I asked claude to help, and all I had to do was copy and paste the code into the settings.json and text.json files. however, I want a permanent solution as I need to spend time on actually using the debugger rather than setting it up each time.

How can I fix this permanently?

Download from WinLibs: https://winlibs.com/

GCC is a more advanced, more up-do-date C compiler (with numerous other compilers too) than Microsoft's "cl". Here's a link to the GNU C language extensions available when compiling with GCC: https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html

"Hello world" source code:

#include "stdio.h"
int main(...

▶ Play video
chrome knollBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

left snow
#

tasks.json:

{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\mingw64\bin\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "GCC build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file",
"miDebuggerPath": "C:\mingw64\bin\gdb.exe"
}
]
}

marble verge
#

I want a permanent solution as I need to spend time on actually using the debugger rather than setting it up each time
don't use vsc 'build system' then.

#

the cmake extension has some debugger integration - you can use it instead (you'd need to learn how to use cmake in the first place though). otherwise, you can either launch gdb manually or fiddle with launch.json every time

left snow
left snow
marble verge
left snow
#

thank you!

marble verge
#

np

chrome knollBOT
#

@left snow Has your question been resolved? If so, type !solved :)

left snow
#

!solved