Windows10中vscode运行代码出现以下错误:Unable to start debugging. Unable to establish a connection to GDB. Debug

 1.某天使用vscode,链接代码的时候出现如下错误:Unable to start debugging. Unable to establish a connection to GDB. Debug output may contain more information.

Windows10中vscode运行代码出现以下错误:Unable to start debugging. Unable to establish a connection to GDB. Debug

2.并且在编译和链接的时候都弹出了terminal,并且在vscode的terminal中也显示了编译的结果。即使我在launch.json中设置"externalConsole": false

3.当然主要还是链接出现错误,导致没法看代码结果

4.看有人说是将"externalConsole": false,设置为True就行。那么设置好:"externalConsole": true,

5.这把不报错了,但是在链接的时候没有弹出terminal,vscode内部的terminal中也没有结果。但是在编译的时候还是会弹出terminal并且在vscode内部的terminal中也显示编译。

6.同时链接完之后在vscode的右下角发现了下图这样一个提示(错误):

Windows10中vscode运行代码出现以下错误:Unable to start debugging. Unable to establish a connection to GDB. Debug

7.看他的意思是我是用了旧的console,取消勾选使用旧的console就可以了。

8.好的,那么先取消勾选旧的console

9.要想取消勾选console,首先打开cmd,

10.在cmd中右键选择“属性”:

Windows10中vscode运行代码出现以下错误:Unable to start debugging. Unable to establish a connection to GDB. Debug

11.出现属性设置面板:

Windows10中vscode运行代码出现以下错误:Unable to start debugging. Unable to establish a connection to GDB. Debug

 12.取消勾选使用旧版控制台选项

Windows10中vscode运行代码出现以下错误:Unable to start debugging. Unable to establish a connection to GDB. Debug

13.点击确定,再回到vscode再试试

14.这把好了。在编译和链接阶段都不弹出terminal了,只在vscode内部的terminal中显示编译和链接信息。

15.运行之后直接在vscode中显示结果。

解决