Skip to content

Instantly share code, notes, and snippets.

@gphg
Last active June 5, 2020 10:32
Show Gist options
  • Save gphg/6e4c413da8311212bd6d912a4471ddbc to your computer and use it in GitHub Desktop.
Save gphg/6e4c413da8311212bd6d912a4471ddbc to your computer and use it in GitHub Desktop.
VSCode tasks.json for C/C++ programming on Ming-w64. See comments for more detail.
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++.exe build active file",
"command": "${env:MSYS2_ROOT}\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}",
"env": {
"PATH": "${env:MSYS2_ROOT}\\mingw64\\bin;${env:PATH}",
}
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
@gphg
Copy link
Author

gphg commented Jun 5, 2020

Description: For security reason, I don't have msys2 binaries on my %PATH%, but I want to make it works while I'm having C/C++ coding session without have to change the Environment Variable every single time.

  1. Please pay attention that I have %MSYS2_ROOT% defined on Windows User's Environment Variable. It points to root of msys2 (in my case it's C:\Users\hexat\scoop\apps\msys2\current). You might want to declare the variable if not defined yet OR substitute it with full path. Pay attention on env.PATH too.

  2. On this line, it perpend %PATH% with mingw64 binaries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment