Using VS Code on Linux

Last updated: 2022-02-20

This tutorial was tested on Ubuntu 20.10, but it should work too on other versions or distributions. You'll have to install packages manually if you don't have apt.

  1. Clone the repository by git clone --recurse-submodules -j8 https://github.com/bb1950328/BrickSim.git
  2. Run setup_workspace.sh
  3. Install VS Code via a way described in the offical VS Code docs
  4. Open VS Code and install the ms-vscode.cpptools and ms-vscode.cmake-tools extensions
  5. Press Ctrl + Shift+ P and type "preferences: Open Settings (JSON)"
    After pressing Ctrl+Shift+P and typing "preferences: Open Settings (JSON)"
    Hit Enter or click the first result and add the following text:
    1
    2
    3
    4
    5
    6
    
    {
       "cmake.buildDirectory": "${workspaceFolder}/cmake-build",
       "cmake.debugConfig": {
          "cwd": "${workspaceFolder}"
       },
    }
    
  6. Open the BrickSim folder in VS Code. You should get a notification like this one:
    screenshot of VS Code notifications after opening the project the first time Click "Yes" on that notification
  7. You will get a prompt looking like this: select cmake kit prompt in VS Code on linux Select the one with /bin/gcc, the second last element on this screenshot
  8. The "Play" button in the bottom status bar doesn't choose the correct working directory as described in microsoft/vscode-cmake-tools#1395
    You have to run it from the menu on the left side: run configuration in VS Code on linux