簡體   English   中英

如何在 Windows 上為 C++ 配置 Visual Studio Code?

[英]How to configure Visual Studio Code for C++ on Windows?

我在 Windows 上配置launch.json文件時遇到問題,它顯示錯誤消息

調試適配器進程意外終止。

我已經設置了“MinGW”並配置了 g++ 編譯器,現在 Visual Studio Code 可以正確編譯。 當我按Ctrl + Shift + B 時,它會在項目文件夾中創建一個.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"]
}

這可能是錯誤的,但我想您需要使用 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/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM