C++ Getting Started

C++ Getting Started


C++ Getting Started

To start with, I’ll be covering these things in today’s tutorial:

  • Installation of  C++ IDE(like Code::Blocks, Eclipse, and Visual Studio)
  • Install Extension C/C++ for Visual Studio Code
  • Installation of compiler for Example: Install MinGW-x64#
  • C++ Start Now with code

C++ Install IDE

An IDE (Integrated Development Environment) is used to edit AND compile the code.

Popular IDE's include Code::Blocks, Eclipse, and Visual Studio. These are all free, and they can be used to both edit and debug C++ code.

Note: Web-based IDE's can work as well, but functionality is limited.

We will use VS Code in our tutorial, which we believe is a good place to start.

Install Extention C/C++ for 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.

        

Installation of compiler for Example: Install MinGW-x64#

We will install Mingw-w64 via MSYS2, which provides up-to-date native builds of GCC, Mingw-w64, and other helpful C++ tools and libraries. You can download the latest installer from the MSYS2 page or use this link to the installer.

Add the MinGW compiler to your path#

Add the path to your Mingw-w64 bin folder to the Windows PATH environment variable by using the following steps:

  1. In the Windows search bar, type 'settings' to open your Windows Settings.
  2. Search for Edit environment variables for your account.
  3. Choose the Path variable in your User variables and then select Edit.
  4. Select New and add the Mingw-w64 destination folder path, with \mingw64\bin appended, to the system path. The exact path depends on which version of Mingw-w64 you have installed and where you installed it. If you used the settings above to install Mingw-w64, then add this to the path: C:\msys64\mingw64\bin.
  5. Select OK to save the updated PATH. You will need to reopen any console windows for the new PATH location to be available.

C++ Start Now with code

Let's create our first C++ file.

Open VS Code and go to File > New > Empty File.

Write the following C++ code and save the file as p1.cpp (File > Save File as):

For Example: C++ program to display "Hello World! Welcome to OPH"

Output: Hello World! Welcome to OPH