簡體   English   中英

無法在 Visual Studio 代碼中調試我的 c++ 代碼

[英]Not able to debug my c++ code in visual studio code

我不知道我的 vscode 突然發生了什么我無法調試文件雖然我要運行我的 CPP 程序但無法調試請幫助我我花了 2-3 個小時連續嘗試修復我的調試器

我的程序運行良好,編譯器正在創建一個 exe 文件,如下所示在此處輸入圖像描述

當我點擊調試按鈕時,會出現此圖像在此處輸入圖像描述

然后它卡在這個屏幕上在此處輸入圖像描述

當我按下任何一種鍵時它退出並出現普通終端 window 在此處輸入圖像描述

就像它試圖打開外部終端但無法打開它,這就是我想花一整天解決這個問題的原因

Lauch.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++.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

任務.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\MinGW\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: C:\\MinGW\\bin\\g++.exe"
        }
    ]
}

刪除

  1. %USERPROFILE%.vscode\extensions\ms-vscode.cpptools-1.6.0-insiders\install.lock
  2. %USERPROFILE%.vscode\extensions\ms-vscode.cpptools-1.6.0-insiders\debugAdapters

為我工作。 Windows 10

更多信息請查看: https://github.com/microsoft/vscode-cpptools/issues/7971

嘗試將-g添加到標志中。 -g 是啟用調試的標志。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM