Если проект полностью на C ++, не должно быть оснований для выхода из WSL. Сборка и запуск приложения могут быть легко обработаны прямо здесь! Вы можете выполнить сборку из командной строки в bash, используя
g++ -o <outputfile> <inputfiles>
Однако самый простой способ запустить программу - создать конфигурацию сборки в Visual Code. Вам понадобятся 2 файла: запуск. json и задачи. json Чтобы создать файл запуска, нажмите F1 (или откройте командную паллету) и выберите Задачи: настроить задачу по умолчанию. Это должно выглядеть примерно так.
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}", //input files
"-o",
"${fileDirname}/a.out" //output file
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Чтобы создать запуск. json, go на вкладке «отладка» и выберите «создать запуск. json файл». Он должен выглядеть примерно так
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/a.out", //output file
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
с обоими этими файлами на месте, все, что вам нужно сделать, это нажать кнопку запуска, как в Visual Studio.