Vscode linux setup issues

Hey, I would like to use vscode in ubuntu 20.04 but unfortunately am encountering some obstacles. The c_cpp_properties.json configuration only seems to contain setting for win and mac. Is this the reason it is looking for the compiler in a windows path (see screenshot)? Do I have to edit each c_cpp_properties.json to add a linux config?

Another problem is that the tasks defines in .vscode/tasks.json do not show up (see screenshot). Why is this the case?

Thanks for any suggestions,
Martin

Hmm, I wonder where it’s getting that windows path from. I don’t see that anywhere in the configuration files…

I have not actually tried using VS Code on a linux machine yet. I can look into this shortly. In the meantime, you may be able to just copy the whole section labeled “macOS” and change it to “Linux”.

Once we can confirm a correct configuration for Linux we can add it to all of the projects at once using the helper.py utility. So no need to manually tweak every single one.

I also find the windows path quite puzzling. Apart from that, introducing a Linux section does not seem to solve the missing tasks issue. Any ideas regarding this? Btw, the default path of the compiler is /usr/bin/arm-none-eabi-g++ . From the terminal make works fine.

OK so we don’t have a config for linux in there at the moment.
You can edit .vscode/c_cpp_properties.json to look like this

{
  "configurations": [
    {
      "cStandard": "c11",
      "compilerPath": "arm-none-eabi-g++.exe",
      "cppStandard": "c++17",
      "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
      ],
      "includePath": [
        "${workspaceFolder}/**",
        "${workspaceFolder}/../../libdaisy/**",
        "${workspaceFolder}/../../DaisySP/**"
      ],
      "name": "Win32",
      "windowsSdkVersion": "10.0.17763.0"
    },
    {
      "cStandard": "c11",
      "compilerPath": "/usr/local/bin/arm-none-eabi-g++",
      "cppStandard": "c++17",
      "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
      ],
      "includePath": [
        "${workspaceFolder}/**",
        "${workspaceFolder}/../../libDaisy/**",
        "${workspaceFolder}/../../DaisySP/**"
      ],
      "name": "macOS"
    },
    {
      "cStandard": "c11",
      "compilerPath": "arm-none-eabi-g++",
      "cppStandard": "c++17",
      "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
      ],
      "includePath": [
        "${workspaceFolder}/**",
        "${workspaceFolder}/../../libdaisy/**",
        "${workspaceFolder}/../../DaisySP/**"
      ],
      "name": "Linux"
    }
  ],
  "version": 4
}

This will add a Linux config. Then launch the command palette with Ctrl-Shift-p, punch in config, select C/C++: Select a Configuration, and choose Linux. Once you relaunch VS Code everything should work OK.

I’m going to look into adding this to DaisyExamples soon, so once that’s taken care of you can update your local repo and this will be fixed for all of the examples.

2 Likes

I was able to resolve the issue by adding a Linux config and selecting it. I did have to relaunch VS Code however. Does that work for you?

This works for me, thanks! However, one has to open a specific example’s directory (like DaisyExamples/seed/Blink) while it would be more convenient to open DaisyExamples and then just select and run examples in the subdirectories.

Btw, the strange windows path mentioned above comes from DaisyExamples/.vscode/c_cpp_properties.json. This might also have to be made platform specific.

Oh! I see what happened. Yeah the way we have it set up now is aimed at having the user open the particular example as the “folder” @shensley set this up, so I think he has more details about why it’s set up that way. I remember there being some debate on the topic though, and for one reason or another that’s how it had to be.

@meigel I agree it would be a lot easier to simply open the DaisyExamples folder.

As far as I can tell, all tasks, etc. are tied to the “workspace” (i.e. the directory that is opened in VS Code), meaning that it wouldn’t be possible to use the shortcut keys (build, launch, etc.) when working on a single example.

That said, I do like the idea of adding a global DaisyExamples/.vscode/ directory that could potentially build/launch examples, but there doesn’t seem to be a programmatic way to do this without adding an explicit build_seed_blink, etc. for each example. If you know some way around that that I’m not aware of please do let me know.