-4

So my teacher is wants the class to install C++, and I don't know how to do it. Please help me set it up in Visual Studio Code because it's the IDE I'm most familiar with. Please explain it in the simplest way possible.

I tried installing vscode and c++ extension but library files are missing

drescherjm
  • 10,365
  • 5
  • 44
  • 64
  • you need a compiler, the VS Code extensions are just helpers in writing code (code completion, instellisense, etc.) Check out the [official doc from microsoft](https://learn.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=msvc-170), it helps you install everything you need. I also suggest using [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/) for C/C++ if you're a starter, i think it's easier. – Zoltán Dec 06 '22 at 17:19
  • Your question is too general, don't expect anyone to write a tutorial for you. There are tons of beginner friendly getting started with C/C++ material out there already (videos, blogs, tutorials, official documents), look around and if you get stuck, get back here with specific questions. – Zoltán Dec 06 '22 at 17:29
  • I changed the title and added a `visual-studio-code` tag because [Visual Studio](https://visualstudio.microsoft.com/vs/community/) is a very different IDE than [VSCode.](https://code.visualstudio.com/download) – drescherjm Dec 06 '22 at 20:02
  • 1
    Use visual studio 2022 community edition it supports c++ out of the box – Richard Bamford Dec 06 '22 at 20:04

1 Answers1

0

If you are going to edit and execute on Windows, you have to install either Visual Studio regardless or g++ under MinGW. These instructions are very detailed:

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

To configure VSCode with MS compiler:

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

To configure VSCode with gcc on Windows:

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.

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

Then install the C++ extensions for VSCode.

Then I recommend you install cmake for Windows. Although the tutorials will teach you how to build a single file, you will need more for large projects.

https://cmake.org/install/

Create a CMakeLists.txt and then use the cmake-gui to create the Visual Studio project files. All this is outside Visual Studio Code.

To build from inside VSCode I found it particularly cumbersome. I'd rather Alt-Tab and build the project manually by either calling 'make' or building inside 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. Not only you will have way more support for your questions but also the Visual Studio debugger is arguably the best in the market.