Using VS Code on Windows

Last updated: 2022-02-20

  1. Download MSYS2 from https://www.msys2.org/ and follow the installation instructions there.
  2. Execute the following command in a MSYS2 Shell to install git: pacman -S git
  3. add C:\msys64\mingw64\bin to PATH
  4. Download and install VS Code from here if you haven't already
  5. Install the extensions ms-vscode.cpptools and ms-vscode.cmake-tools
  6. Clone the repository by git clone --recurse-submodules -j8 https://github.com/bb1950328/BrickSim.git
  7. Run setup_workspace.sh
  8. Open the BrickSim folder in VS Code. you should get the notifications like in the following screenshot (at least the first one):
    screenshot of VS Code notifications after opening the project the first time
    click "yes" on the first notification, we'll deal with the second one later.
  9. Now it's time to adjust some settings:
    1. 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.
    2. add the following text:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      
      {
         "cmake.configureOnOpen": true,
         "cmake.cmakePath": "C:\\msys64\\mingw64\\bin\\cmake.exe",
         "cmake.generator": "MinGW Makefiles",
         "cmake.buildDirectory": "${workspaceFolder}/cmake-build",
         "cmake.mingwSearchDirs": [
            "C:\\msys64\\mingw64\\bin"
         ],
      
         "cmake.debugConfig": {
            "cwd": "${workspaceFolder}"
         },
      
         "terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe",
         "terminal.integrated.shellArgs.windows": ["-li"],
         "terminal.integrated.env.windows": {
            "MSYSTEM": "MINGW64",
            "CHERE_INVOKING": "1",
         },
      }
      
      Maybe you already have some settings here so make sure they don't contradict each other.
    3. Save the settings.json file.
    4. Now press Ctrl+Shift+P and type "CMake: Edit User-Local CMake Kits"
      After pressing Ctrl+Shift+P and typing "CMake: Edit User-Local CMake Kits"
    5. Insert the following code:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      
      [
         {
            "name": "Mingw64 GCC",
            "compilers": {
               "C": "C:\\msys64\\mingw64\\bin\\gcc.exe",
               "CXX": "C:\\msys64\\mingw64\\bin\\g++.exe"
            },
            "preferredGenerator": {
               "name": "MinGW Makefiles",
               "platform": "x64"
            },
            "environmentVariables": {
               "PATH": "C:/msys64/mingw64/bin/"
            }
         }
      ]
      
    6. Save the cmake-tools-kits.json file.
  10. Download git for windows from here and install it if you want git integration in VS Code.
  11. Restart VS Code
  12. You should now be able to launch the application using the bottom status bar:
    VS Code status bar with mouse hovering the run icon