How to debug application in Linux + VS Code?

I have the intellisense related things up and running in VS Code in Linux, but when I try to compile, the compiler complains about JuceHeader.h not being found. This to me sounds like VS Code is just trying to compile whatever it finds from the project folder, instead of using what if finds in the makefile. VS Code should have its paths pointing to the makefile.

Any suggestions how to get the thing compiling according to the makefile Projucer has made AND to run in VS Code’s debug mode?

I guess, the only way to get work with vs code is to go the cmake way. You can load cmake projects in almost every ide on Linux (qt creator, vs code, clion,…).

Hi Kraku, I use Projucer, VS Code and Linux and the way I have it working is by setting up ‘.vscode/tasks.json’ to do the build and a ‘.vscode/launch.json’ to run the debugger.

tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "make",
            "type": "shell",
            "command": "cd ${workspaceFolder}/Builds/LinuxMakefile && make -j 6 CONFIG=Debug",
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

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": "Make and debug in plugin host",
            "type": "cppdbg",
            "request": "launch",
            "program": "<PATH_TO_JUCE_HERE>/extras/AudioPluginHost/Builds/LinuxMakefile/build/AudioPluginHost",
            "args": [
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "make",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

In the above config, you will need to put your JUCE path in and already have the Audio Plugin Host built to use it.

You can set up tasks to do whatever you want, which are then called by the ‘launch’ configuration. For example, you can have task just to run the unit tests, or to build with different flags, etc.

The configs then can debug in any way you want - I have one for debugging in Audio Plugin Host (which loads quite quickly) and one for debugging in Reaper (for when I need to test more advanced features).

Hope that helps!

2 Likes

Thank you! I’ll try that.

What I’m debugging is an audio application I’m writing. Not a plugin. So there won’t be any plugin host in my debugging system.

Cool, then I guess you already figured out to change the "program": line to your program.