【问题标题】:How to configure Visual Studio Code for C++ on Windows?如何在 Windows 上为 C++ 配置 Visual Studio Code?
【发布时间】:2017-02-10 15:16:18
【问题描述】:

我在 Windows 上配置 launch.json 文件时遇到问题,它显示错误消息

调试适配器进程意外终止。

我已经设置了“MinGW”并配置了 g++ 编译器,现在 Visual Studio Code 可以正确编译。当我按下 Ctrl+Shift+B 时,它会在项目文件夹中创建 a.exe 文件。

我的 launch.json 文件:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch (Windows)",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceRoot}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": false
        },
        {
            "name": "C++ Attach (Windows)",
            "type": "cppvsdbg",
            "request": "attach",
            "processId": "${command.pickProcess}"
        }
    ]
}

我的 task.json 文件:

{
    "version": "0.1.0",
    "command": "g++",
    "isShellCommand": true,
    "showOutput": "always",
    "args": ["-std=c++11","-g", "main.cpp"]
}

【问题讨论】:

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


    【解决方案1】:

    这可能是错误的,但我想您需要使用 microsoft cl.exe 编译器(而不是 gcc)编译您的 .c/.cpp 文件才能在其上使用 microsoft 调试器。要为cl 设置路径,请使用参数x86x64(取决于您需要什么)调用vcvarsall.bat,然后将cl 转换为您的source file。顺便检查一下这篇文章(准确配置 json 的部分)以确保您在哪里做错了https://www.40tude.fr/blog/how-to-compile-cpp-code-with-vscode-cl/

    【讨论】:

    猜你喜欢
    • 2023-03-26
    • 2021-06-16
    • 1970-01-01
    • 2023-01-17
    • 1970-01-01
    • 2022-11-26
    • 2020-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多