NOTE: We will be using Visual Studio Code. Click here to download Visual Studio Code.
C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS.
- Open VS Code.
- Select the Extensions view icon on the Activity bar or use the keyboard shortcut (
Ctrl+Shift+X
). - Search for
C++
. - Select Install.
- After you install the extension, also search for Code Runner extension and install it.
C++ is a compiled language meaning your program's source code must be translated (compiled) before it can be run on your computer.
The C/C++ extension does not include a C++ compiler or debugger. You will need to install these tools or use those already installed on your computer.
Most Linux distributions have the GNU Compiler Collection (GCC)
installed and macOS users can get the Clang
tools with Xcode
.
-
Checking for the GCC compiler
g++
:g++ --version
-
Checking for the Clang compiler
clang
:clang --version
If you don't have a compiler installed, we will describe how to install the Minimalist GNU for Windows (MinGW) C++ tools (compiler and debugger). MinGW is a popular, free toolset for Windows.
If you are running VS Code on another platform, you can read the vlang/LLVM Compiler and Debugger (For-macOS) , which cover C++ configurations for Linux and macOS.
- Follow the Installation instructions on the MSYS2 website to install
Mingw-w64
. - Make sure to run each required Start menu and
pacman
command. - Add the MinGW compiler to your path: follow the video below to do that
https://www.youtube.com/watch?v=7jil6-QRsH0
To check that your Mingw-w64 tools are correctly installed and available, open a new Command Prompt and type:
gcc --version
g++ --version
gdb --version
If you don't see the expected output or g++ or gdb is not a recognized command, make sure your PATH entry matches the Mingw-w64 binary location where the compiler tools are located.
NOTE
Follow the video to know How to Install MinGW (MSYS2) and Run C, C++ program in VS Code for Windows
In this tutorial, you will learn to configure Visual Studio Code on macOS to use the Clang/LLVM compiler and debugger.
To successfully complete this tutorial, you must do the following:
-
Install Visual Studio Code on macOS.
-
Install the C++ extension for VS Code. You can install the C/C++ extension by searching for
c++
in the Extensions view (Ctrl+Shift+X
).
- Clang may already be installed on your Mac. To verify that it is, open a macOS Terminal window and enter the following command:
clang --version
- If Clang isn't installed, enter the following command to install the command line developer tools:
xcode-select --install
https://www.youtube.com/watch?v=f0vVV4NPmjQ
How to Contribute: 🔝
- Just fork the project and clone it into your machine
- Then make your contribution and upload it to your fork repository
- Then click on pull request
NOTE
If you face any issues kindly let us know