0
votes

I am following that tutorial from the VScode team : https://code.visualstudio.com/docs/cpp/config-wsl#_debug-helloworldcpp

I have run and built another c++ project. It compiles but the project kraches at runtime, so I decide to debug it.

So i want to debug and I use gdb as proposed by this good tutorial. When I execute the debugging with "F5", I have that 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": "g++ build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "executable.out",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++ build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

I have modified the "program" section to put the name of my executable ( executable.out) , which is located in the "workspaceFolder"

So I don't understand the error message I get when I do "F5" :

launch : program "executable.out" does not exist

enter image description here

Could someone explain to me how to solve that ? I thought a lot before posting this question.

Thanks a lot in advance. Best regards

2

2 Answers

1
votes

Use absolute path in program:

"program": "${workspaceFolder}/executable.out"
1
votes

I assume you are using Linux, since you are using g++ compiler. Did you compile your cpp file to "executable.out", e.g.

g++ main.cpp -o executable.out

Your launch.json configuration look fine to me. It should work.