【问题标题】:C++ Setup For VS CodeVS 代码的 C++ 设置
【发布时间】:2022-01-15 02:30:59
【问题描述】:

所以我的老师想让班级安装C++,我不知道该怎么做。请帮我在 Visual Studio Code 中设置它,因为它是我最熟悉的 IDE。请用最简单的方式解释一下。

【问题讨论】:

  • Visual Studio 还是 Visual Studio Code? Windows 还是 Linux?
  • @Jellyboy Visual Studio 代码,Windows
  • 您是要在 Windows 上编码还是在 Windows 上编辑并在 Linux 上执行?
  • 绝对在 Windows 上编码并在 Windows 上运行

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


【解决方案1】:

如果你要在 Windows 上编辑和执行,你必须在 MinGW 下安装 Visual Studio 或 g++。这些说明非常详细:

https://code.visualstudio.com/docs/languages/cpp

使用 MS 编译器配置 VSCode:

https://code.visualstudio.com/docs/cpp/config-msvc

在 Windows 上使用 gcc 配置 VSCode:

https://code.visualstudio.com/docs/cpp/config-mingw

我推荐的另一个替代方法是使用 Windows WSL,它就像 Windows 中的 Linux。

https://code.visualstudio.com/docs/cpp/config-wsl

然后安装 VSCode 的 C++ 扩展。

那我推荐你为 Windows 安装 cmake。虽然教程将教您如何构建单个文件,但对于大型项目,您需要更多。

https://cmake.org/install/

创建一个 CMakeLists.txt,然后使用 cmake-gui 创建 Visual Studio 项目文件。所有这些都在 Visual Studio Code 之外。

要从 VSCode 内部构建,我发现它特别麻烦。我宁愿 Alt-Tab 并通过调用“make”或在 Visual Studio 中构建来手动构建项目。但这是您的偏好。

但是,如果您在 Windows 上进行编辑并在 Windows 上运行,我强烈建议您在 Visual Studio 本身中运行。不仅您将获得对您的问题的更多支持,而且 Visual Studio 调试器可以说是市场上最好的。

【讨论】:

  • 所以我设置了它,但它显示:#include 检测到错误。请更新您的 includePath。此翻译单元 (C:\Documents\C++\Test.cpp) 禁用 Squiggles。我一直在尝试在网上寻找解决方案,但找不到我真正能理解的解决方案。
  • 请编辑您的问题并显示您的c_cpp_properties.json。此外,您可能需要显示安装 mingw 的位置。
猜你喜欢
  • 2017-06-13
  • 2017-07-23
  • 1970-01-01
  • 1970-01-01
  • 2021-10-08
  • 1970-01-01
  • 2020-10-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多