I have no rep so I can't upvote but I found the same solution for vscode as @ioaniatr in the https://code.visualstudio.com/docs/cpp/config-mingw?source=post_page-----a360be1487c...#_modifying-tasksjson
{
"tasks": [
  {
    "type": "cppbuild",
    "label": "C/C++: g++.exe build active file",
    "command": "C:\\msys64\\ucrt64\\bin\\g++.exe",
    "args": [
      "-fdiagnostics-color=always",
      "-g",
      "${fileDirname}/*.cpp",
      "-o",
      "${fileDirname}\\${fileBasenameNoExtension}.exe",
    ],
    "options": {
      "cwd": "${fileDirname}"
    },
    "problemMatcher": ["$gcc"],
    "group": {
      "kind": "build",
      "isDefault": true
    },
    "detail": "Task generated by Debugger."
  }
],
"version": "2.0.0"
}
I followed this guide for setting up a compiler: https://www.youtube.com/watch?v=DMWD7wfhgNY