【问题标题】:Can latest version VSCode debug C++ with C++ extension and MSVC?最新版本的 VSCode 可以使用 C++ 扩展和 MSVC 调试 C++ 吗?
【发布时间】:2021-07-13 04:33:34
【问题描述】:

VSC更新到新版本(1.58.0)后,无论是InternalConsole还是ExternalConsole都不能自动运行cl.exe编译成功的.EXE文件。我已经配置了 .JSON 文件,而它在以前版本的 VSC 中运行良好。 JSON文件代码如下。

// lauch.json
"version": "0.2.0",
"symbolsearchpath": "https://msdl.microsoft.com/download/symbols",
"configurations": [
    {
        "name": "cl.exe build and debug active file",
        "type": "cppvsdbg",
        "request": "launch",
        "program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "console":"externalTerminal",
        "preLaunchTask": "cl.exe build active file"
    }
]
// task.json
"version": "2.0.0",
"tasks": [
    {
        "type": "shell",
        "label": "cl.exe build active file",
        "command": "cl.exe",
        "args": [
            "/Zi",
            "/EHsc",
            "/Fe:",
            "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "${file}"
        ],
        "problemMatcher": ["$msCompile"],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]

按 F5 后,VSC 可以编译 C++ 项目,但即使我提交了一些断点,也无法运行或调试。

【问题讨论】:

  • 您能否更清楚地解释一下当您尝试运行程序时会发生什么?有错误吗?您是否检查了各种输出窗口是否有错误?
  • 感谢您的回复!我已经解决了这个由 Windows Debugger 未安装引起的问题。我尝试在扩展(Windows 调试器)完全安装之前调试或运行我的程序,会遇到这个问题。

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


【解决方案1】:

我已经解决了这个问题。当用户尝试运行或调试他们的程序时,VSC 无法自动运行 .EXE 文件的问题将在 VSC(Windows 调试器 C++)的扩展未完全安装之前遇到。更新 VSC 后,请等待其完全安装。
有关 VSC 上的更多 C++ 编译器配置
MSVC
https://code.visualstudio.com/docs/cpp/config-msvc
g++
https://code.visualstudio.com/docs/cpp/config-mingw

【讨论】:

    猜你喜欢
    • 2022-07-12
    • 2021-05-10
    • 1970-01-01
    • 2010-09-27
    • 1970-01-01
    • 1970-01-01
    • 2018-11-03
    • 2019-06-21
    相关资源
    最近更新 更多