Developing with Visual Studio Code on Ubuntu#

This topic describes the steps needed to setup Visual Studio Code for PrimoBurner development on Ubuntu. These steps have been verified to work on Ubuntu 22.04.3 LTS.

Visual Studio Code#

Download and install from Visual Studio Code site.

Open Visual Studio Code and press Ctrl + Shift + P. Select Shell Command: Install 'code' command in PATH.

Also install the C/C++ Extension Pack.

Create CMake project#

Follow the steps in Create a Command Line Tool using CMake to create a CMake project.

Automate the build#

Add the following Visual Studio Code specific files to the .vscode subdir:

.vscode/tasks.json#

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "type": "shell",
            "linux": {
                "command": "${workspaceFolder}/build.sh",
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

.vscode/launch.json#

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch (gdb)",
            "type": "cppdbg",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "linux": {
                "program": "${workspaceFolder}/build/debug/enum-devices",
                "MIMode": "gdb",
            },
        }    
    ]
}

Test the build#

Test the build by pressing Ctrl + Shift + B. Visual Studio Code should execute the build.sh script automatically.

Test the debugging#

Set a breakpoint on the first line of int main(int argc, const char *argv[]) inside src/main.cpp. Press F5 to launch the debugger. It should stop at the breakpoint.