新下载的vscode,代码运行不了,这咋弄啊
最省事的方法就是卸载VS重新下载,记得勾选C++
g++.exe所在文件夹添加到PATH里。
task.json添加
{
"label": "g++dbbuild",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"command": "g++.exe",
"args": [
"${file}",
"-g"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
launch.json添加:
{
"name": "G++ Debug",//debug页面里选这一项
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "g++dbbuild",//要与task.json里的label对应
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}