vscode配置C++报错unable to start debugging.unexpected GDB output from command
unable to start debugging.unexpected GDB output from command或preLaunchTask“g++”已终止,退出代码为1的可能解决方案
解决方案:文件目录不能存在中文

首先你要确定你是否已经添加全局变量

你要确定你的配置文件没有错误
launch,json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| { "version": "0.2.0", "configurations": [ { "name": "task g++", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "miDebuggerPath": "D:\\MinGw\\mingw64\\bin\\gdb.exe", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, } ], "preLaunchTask": "task g++" } ] }
|
task,json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| { "version": "2.0.0", "tasks": [ { "label": "task g++", "type": "shell", "command": "g++", "args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "${workspaceFolder}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, } ] }
|
如果都没错,那就是上面第一张图片中标红的原因——文件目录名中含中文,需要改成全英才行,因为是当都放在桌面,所以需要改变桌面存放文件的默认地址

