【问题标题】:How to configure Visual Studio Code to debug with cygwin, cmake and gcc如何配置 Visual Studio Code 以使用 cygwin、cmake 和 gcc 进行调试
【发布时间】:2020-10-19 16:34:01
【问题描述】:

我必须使用 cygwin 和 cmake 来构建发布和调试。 (cygwin 包包含构建过程所需的所有工具/库(cmake、gcc、boost))

我已经找到this 现在允许我在 Visual Studio 代码控制台中运行 cmake 和构建脚本,并且正确生成可执行文件。

我已经为 Visual Studio Code 安装了扩展 C/C++。

但是如何配置 Visual Studio 代码进行调试呢?

【问题讨论】:

  • 我不明白为什么要使用 Visual Studio 来使用 cygwin 之类的东西。 Visual Studio 已经有一个 linux 项目模板,可以在你的远程 shell 上编译/调试。
  • @MichaelChourdakis OP 使用 VSC,而不是 VS。

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


【解决方案1】:

通过this构建后,调试所需的只是一个如下结构的launch.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": "(gdb) Starten",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/PATH_2_YOUR_DEBUG.exe",//This you need to define
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\cygwinPath\\bin\\gdb.exe",//This you need to define
        "setupCommands": [
            {
                "description": "Automatische Strukturierung und Einrückung für \"gdb\" aktivieren",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    }
]
}

之后你可以在PATH_2_YOUR_DEBUG.exe的源码中设置断点,然后按F5。

【讨论】:

    猜你喜欢
    • 2016-08-31
    • 2019-10-31
    • 2012-01-10
    • 2021-02-09
    • 2021-11-08
    • 1970-01-01
    • 2023-02-20
    • 2018-12-09
    • 2019-08-19
    相关资源
    最近更新 更多