How to set up VSCodium to compile and debug JUCE projects using makefiles written by projucer (Debian GNU+Linux)

Hello everybody:
I hope you are all in good health.
I am quite a beginner with JUCE and not so much with C++. That being said, I bring this setup I wrote for people who are trying to use VS Codium on GNU+Linux (in my case, Debian) and want to build projects using the makefile written by Projucer. I hope this post is not found redundant. It is not, as far as I could search.
First of all, we use the Projucer to generate the corresponding auxiliary folders and files inside the project folder. The folders structure should be something like this:

(parent folder)/ProjectName/Builds/LinuxMakefile
(parent folder)/ProjectName/Builds/MacOSX
(parent folder)/ProjectName/Builds/VisualStudio2019

Inside the first folder we should find the makefile. Normally we would issue the ā€˜make’ command from console from this folder and then a new ā€˜build’ subfolder is created, inside of which the executable file will be placed.

We should create a hidden folder at the same level as ā€˜Builds’ folder, such as:

(parent folder)/ProjectName/.vscode

This folder should contain four json files (c_cpp_properties.json, launch.json, settings.json and tasks.json) with the following contents:

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/Source", 
                "${workspaceFolder}/JuceLibraryCode/**", 
               // Edit the path to your JUCE modules and user modules here.
               // I added them just in case one wants to include other headers than those initially selected with Projucer
                "/home/<user>/<path to>/JUCE/modules/**",     
                "/home/<user>/<path to>/JUCE/userModules/**"    
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Compile with make and launch JUCE project.",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/Builds/LinuxMakefile/build/${workspaceFolderBasename}",
            "args": [],
            "stopAtEntry": false,
             "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "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
                }
            ],
            "preLaunchTask": "build",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

Settings.json: (this is really optional, it helps to point out errors)

{
   "C_Cpp.errorSquiggles": "enabled"
}

Tasks.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build",
      "type": "shell",
      "command": "make",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "options": {
        "cwd": "${workspaceFolder}/Builds/LinuxMakefile/"
      }
    }
  ]
}

To debug, just select Main.cpp as active file and press ā€œStart debuggingā€ or ā€œRun build taskā€ and it should work.
Thank you all for all the knowledge you share in this forum. Happy coding!

Gus Carr

4 Likes

This is a very nice post. I have seen bits and pieces of this in the forums but not all nicely put together like this. It is reassuring to compare this to my setup! One enhancement you could make is to put ā€œ-j 8ā€ (or similar) in your make command to speed up compilation.

Also, for making plugins, I like to have a separate build task to build the Plugin Host, and a debug ā€˜launch’ to launch it.

Thanks, @AdamVenn. I’m glad to read you reply. I just tried to post what I wanted to find.
I’ll follow your advice as well.

I have another enhancement!

  • Download juce.natvis from @jimc’s lifesavingly fantastic repo here.
  • Put juce.natvis in your .vscode folder.
  • Add the following to launch.json
"visualizerFile": "${workspaceFolder}/.vscode/juce.natvis",
"showDisplayString": true,