简体   繁体   English

VS 代码的 C++ 设置

[英]C++ Setup For VS Code

So my teacher is wants the class to install C++, and I don't know how to do it.所以我的老师想让class安装C++,我不知道怎么做。 Please help me set it up in Visual Studio Code because it's the IDE I'm most familiar with.请帮我在 Visual Studio Code 中设置它,因为它是我最熟悉的 IDE。 Please explain it in the simplest way possible.请以最简单的方式解释它。

If you are going to edit and execute on Windows, you have to install either Visual Studio regardless or g++ under MinGW.如果要在 Windows 上编辑和执行,则必须安装 Visual Studio 或 g++ 下的 MinGW。 These instructions are very detailed:这些说明非常详细:

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

To configure VSCode with MS compiler:使用 MS 编译器配置 VSCode:

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

To configure VSCode with gcc on Windows:要在 Windows 上使用 gcc 配置 VSCode:

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

Another alternative that I recommend is to use Windows WSL which is like a Linux inside Windows.我推荐的另一种选择是使用 Windows WSL,它类似于 Windows 内部的 Linux。

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

Then install the C++ extensions for VSCode.然后为 VSCode 安装 C++ 扩展。

Then I recommend you install cmake for Windows.然后我建议您为 Windows 安装 cmake。 Although the tutorials will teach you how to build a single file, you will need more for large projects.尽管教程将教您如何构建单个文件,但对于大型项目,您将需要更多。

https://cmake.org/install/ https://cmake.org/install/

Create a CMakeLists.txt and then use the cmake-gui to create the Visual Studio project files.创建一个 CMakeLists.txt,然后使用 cmake-gui 创建 Visual Studio 项目文件。 All this is outside Visual Studio Code.所有这些都在 Visual Studio Code 之外。

To build from inside VSCode I found it particularly cumbersome.要从 VSCode 内部构建,我发现它特别麻烦。 I'd rather Alt-Tab and build the project manually by either calling 'make' or building inside Visual Studio.我宁愿 Alt-Tab 并通过调用“make”或在 Visual Studio 中构建来手动构建项目。 But it's your preference.但这是你的偏好。

But if you are editing on Windows and running on Windows, I'd strongly suggest to run inside Visual Studio itself.但是,如果您在 Windows 上进行编辑并在 Windows 上运行,我强烈建议您在 Visual Studio 本身内部运行。 Not only you will have way more support for your questions but also the Visual Studio debugger is arguably the best in the market.不仅您将获得对您的问题的更多支持,而且 Visual Studio 调试器可以说是市场上最好的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM