Development Environment Setup For C++

An In-Depth Look At C++ Environment Setup With Examples.

In this Free C++ Training Series, we will learn more about C++ Environment Setup in this tutorial.

We will look into the details about how we can execute C++ programs. For this, we will need to set up an environment on our local machine or we can also do it by using other means.

C++ programs can be executed on a variety of operating systems like Windows, Linux, Mac OS, etc. Each operating system has its own features & behavior and based on that the approach of setting up a C++ environment will differ accordingly.

Let us now explore the different ways of executing our C++ programs!!

C++ Environment setup (1)

Local Environment

In order to learn C++ effectively, we need to practice programs before we begin with C++ programming. For this, we need to have a proper environment on our local machine from where we can write C++ programs, compile them and later execute them.

As a part of the local environment setup, we need two most important software on our machine as mentioned below:

#1) Text Editor

Firstly, we need to write programs and save each file with a ‘.cpp’ extension. In order to write these programs, we need a text editor on our machine. Any text editor that allows us to input text should work. It can be as simple as a notepad or an advanced editor like Notepad++. We need this editor to write programs.

Once we finish writing a program, we save this file with an extension ‘.cpp’ and then pass it on to compiler for compiling. This file with .cpp extension is called the ‘source code file’.

Given below is a screenshot of a Notepad++ Editor that is used to write C++ programs:

Notepad++ editor in C++

#2) Compiler

Once we have the C++ program ready, we need to compile the program and execute it. We use a software program called “Compiler” to compile the program.

A compiler is a software that converts a program written in a high-level language (in this case C++) into low-level machine language instructions which the computer can understand. Later, the computer executes each of these instructions to produce the desired results. This set of low-level machine instructions is called an Object code.

Thus in simple terms, compilation can be defined as the conversion of source code into the object code.

In the upcoming section, we will look into the details of setting up compiler on different platforms.

Setting C/C++ Compiler

Linux Operating System

We need to type the following command in order to ensure that our Linux Operating System has the correct version of C++ compiler.

g++ -v

If the compiler is installed correctly on this Linux system, then the above command will launch the C++ compiler and print its version. If an error occurs, then it is required that we read the error and check the documentation again and correct the setup accordingly.

Once the compiler is set up correctly, we can compile any C++ program by giving the following command:

g++ filename.cpp

If the code is error-free, an executable “a.out” will be generated, which when executed will provide us with the desired results.


Note: The above command to execute a.out may differ depending on the version of Linux.

Windows Operating System

C++ is very vast and so are the compilers available for C++. We have a lot of compilers that are available in the Windows out of which some are freely available while some are paid.

Some of the compilers that are freely available are listed below:

  • Cygwin (GNU C++)
  • MINGW (Minimalist GNU for Windows) – GCC version for Windows.
  • Intel C++ for non-commercial development.
  • Microsoft Visual C++ Express edition.
  • Oracle C++

Among all the above compilers, Microsoft Visual C++ compiler is the most popular one. We can either download the free express edition or community edition for this compiler. This is a complete solution IDE and will let us develop everything right from simple programs to big projects.

Recommended Reading  =>> Most Popular C++ Compilers

As this is a readymade IDE, we need not specifically give any command or remember a sequence to compile and execute the C++ programs. We just need to download the appropriate version of MS Visual Studio and install it. Once done, we are ready to use it.

The image given below shows MS Visual Studio installed on a Windows system:

MS Visual Studio on a Windows System

Other C++ IDEs

Apart from the IDEs that are already discussed above, there are still a lot of other IDEs that are present for C++ compilation. If at all you do not want to have a local setup for C++ programming, then you can always compile and execute your programs through various the online compilers that are present.

Popular among these are:

This is an interactive online compiler that allows you to write C++ program online and execute it.

Below is the screenshot which shows a simple program being executed in

codechef ide

Codechef ide is a multi-language compiler. It allows us to select the appropriate language for which you want to execute programs and then you can execute the programs in the required language.

Program creation and its execution will look as shown below:




Online IDES are the best option for people who learn C++ and wish to gain experience with the language by practicing it.

We hope this tutorial was clear enough to gain a deep insight into setting up an environment for C++.

From our upcoming tutorial, we will go for programming with C++ learning with all the Basic C++ concepts.

=> Read Through The Extensive C++ Training Tutorial Series Here