簡體   English   中英

在Windows上為C ++設置VSCode(MSVC)

[英]Setup VSCode for C++ on Windows (MSVC)

我有點困惑,因為我無法使用MSVC在Windows上設置Visual Studio Code來進行C ++開發。 網絡上的所有人都說他們對設置和使用的一切都很滿意,但我找不到任何簡單的指南; 他們中的大多數只是跳過設置部分,並顯示一切有效,包括代碼完成/智能感知和調試支持。

我安裝了Visual Studio 2015 Community Edition(包括調試工具等),Visual Studio Code和Microsoft的C ++擴展。

接下來我需要做什么?

編輯:智能感知這些天開箱即用,這很棒。 但是我的自動生成的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",
            "type": "process",
            "command": "msbuild",
            "args": [
                // Ask msbuild to generate full paths for file names.
                "/property:GenerateFullPaths=true",
                "/t:build"
            ],
            "group": "build",
            "presentation": {
                // Reveal the output only if unrecognized errors occur.
                "reveal": "always"
            },
            // Use the standard MS compiler pattern to detect errors, warnings and infos
            "problemMatcher": "$msCompile"
        }
    ]
}

當我運行此任務時,它似乎無限運行,只輸出到以下內容:

 Executing task: msbuild /property:GenerateFullPaths=true /t:build <

有任何想法嗎?

對於MSVC 2017版本:

  1. 將這些添加到您的包含路徑:

“D:/ Program Files / Microsoft / MSVC2017 / VC / Tools / MSVC / 14.12.25827 / include / *”,

“C:/ Program Files(x86)/ Windows Kits / 10 / Include / 10.0.10240.0 / ucrt”,

“C:/ Program Files(x86)/ Windows Kits / 10 / Lib / 10.0.10240.0 / ucrt / x64”,

您可以相應地更改驅動器名稱和文件夾名稱。

2.在settings.json中更改shell 設置

“terminal.integrated.shell.windows”:“C:\\ WINDOWS \\ System32 \\ cmd.exe”,“terminal.integrated.shellArgs.windows”:[“/ k”,“D:/ Program Files / Microsoft / MSVC2017 / Common7 /工具/ VsDevCmd.bat“]

這將啟用集成終端中的cl命令。

3.按ctrl +`啟用集成終端,輸入cl / EHsc your_cpp_program.cpp進行編譯。

我認為最簡單的方法 - 打開visual studio 2017命令提示符控制台並從那里運行Visual Studio Code IDE,這樣它就會選擇所有必要的編譯器環境變量

暫無
暫無

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

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