I wanted to know how I can set the code runner extension to use the Microsoft Visual C++ compiler. By default, trying to run the code throws an error as it is set to use the g++ compiler.
Asked
Active
Viewed 123 times
1 Answers
0
You need to change the code-runner.executorMap
setting. You can either do this in your user or workspace settings.json file. I believe you'd want something like so:
"code-runner.executorMap": {
"cpp": "cd $dir && cl $fileName /link /out:$fileNameWithoutExt.exe && $dir$fileNameWithoutExt"
}
You can adjust it and add other commandline flags as needed (Ex /W4
, /EHsc
)
You might need to run VS Code from a Visual Studio Developer prompt to get a working environment.

starball
- 20,030
- 7
- 43
- 238