Visual Studio Code is a cross-platform IDE that uses a
tasks.json file to describe how to compile (and perform other tasks) your project. You can run the VSCode in the Windows or in the WSL Ubuntu subsystem. If you wanna run it into the WSL, you must use the Ubuntu/Linux binaries.
Notes on WSL
In the Windows command line, you can run linux commands using
C:\> bash.exe -c <linux command>
For instance, you can run the Linux
C:\> bash -c "gcc -v"
If you have installed multiple linux systems on WSL, e.g. an opensuse and a ubuntu, you must use
opensuse-42 run or
ubuntu run instead of
bash to determine which linux subsystem use at the windows command line.
C:\> ipconfig | opensuse-42 run grep IP | ubuntu run lolcat
In addition, note that the Windows file system can be accessed using
/mnt/<drive letter>/. For instance, if you have a
C:\Projects folder, you can access it from Linux at
Configuring a VSCode in Windows to use the GCC in the WSL Linux
Check the instructions in the website. To use GCC or CLang compilers in Mac or Linux, you may use the
bash with different arguments depending on the task.
You can configure (or create) your own
task.json. You must define the
bash as the command to use. I think almost the same configuration you use for Mac/Linux must work. I changed the "cwd" option.
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"taskName": "compile w/o makefile",
"g++ helloworld.C -o hello"
There are some other Gists you can use as other examples.
NOTE: I have found some MS tutorials on compiling and debugging Linux GCC programs using WSL and Visual Studio but not Visual Studio Code.