【问题标题】:Visual Studio Code using cygwin (not working)使用 cygwin 的 Visual Studio Code(不工作)
【发布时间】:2017-09-26 09:26:17
【问题描述】:

我刚刚安装了 VSCode(在 Windows 上),我正在尝试使用 cygwin 运行 C 编译器。我正在关注这个页面:https://code.visualstudio.com/docs/languages/cpp

我的 c_cpp_properites.jsonlaunch.json 文件很好。我认为这是我的tasks.json 文件的问题:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "taskName": "Build test",
        "type": "shell",
        "command": "g++",
        "args": [
            "-g",
            "test.c"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "problemMatcher": []
    }
]
}

我只是想运行simple Hello World program。正如终端所说,任务运行:

执行任务:g++ -g test.c

并且在输出终端上什么也没有出现。我可以从 cmd 运行 a.exe 文件,它可以工作,但我宁愿在 VSCode 中打印输出。

【问题讨论】:

    标签: windows cygwin visual-studio-code


    【解决方案1】:

    是的,这种行为是设计使然。除非您告诉它,否则构建任务并不打算运行您构建的程序。对于该功能,您需要使用调试器。

    由于您已经在 Cygwin 上安装了 g++,我假设也安装了 gdb。单击VS Code左侧的调试选项卡,单击下拉菜单,然后选择Add Configuration,然后从刚刚打开的launch.json文件中的下拉列表中选择C/C++: (gdb) Launch会为您设置一个空白gdb 配置。

    然后,分别在"program""miDebuggerPath" 中填写a.exe 文件的路径和gdb 可执行文件的路径。

    然后,调试面板中的绿色播放按钮将起作用。当您单击它时,调试会话将开始。

    【讨论】:

      猜你喜欢
      • 2018-07-31
      • 2021-07-23
      • 2019-06-10
      • 1970-01-01
      • 1970-01-01
      • 2016-09-18
      • 2015-08-04
      • 2022-11-18
      • 2017-11-05
      相关资源
      最近更新 更多