【问题标题】:Proble in debuging c++ code with visual studio code, with lunch.json file使用visual studio代码调试c ++代码时出现问题,带有lunch.json文件
【发布时间】:2020-04-15 13:05:34
【问题描述】:

我在 Visual Studio 代码 中调试 c++ 程序时遇到问题。虽然,调试之前工作。我没有更改任何配置或设置。当我今天打开 visual studio code 时,我看到了那个错误。 Image

lunch.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": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++.exe build active file"
        }
    ]
}

我没有更改系统/vc 代码/配置等中的任何内容。 然后,为什么调试停止工作。

【问题讨论】:

  • 可执行文件是否创建成功?错误说它不存在,所以你应该确保它真的被创建了
  • 是的,可执行文件创建成功。它正在运行并产生输出。没有错误。

标签: c++ debugging visual-studio-code


【解决方案1】:

程序设置指定您要调试的程序。这里设置为活动文件夹 ${fileDirname} 和活动文件名,扩展名为 .exe ${fileBasenameNoExtension}.exe,如果 helloworld.cpp 是活动的文件将是 helloworld.exe。
主要问题是vccode无法找到当前文件进行调试。
这些是一些可能对您有用的链接。
Docs

Configuration

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    • 2020-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多