C++ compilers

“Any good software engineer will tell you that a compiler and an interpreter are interchangeable” Tim Berners-Lee

C++ is a compiler based language and so we need a compiler to compile and run a program written in C++.

There are a couple of compilers built to compile C++ source codes but not all of these compilers can run on any operating system.

If the target operating system is Microsoft windows (7, 8, 10 etc.), there are usually two famous compilers that can be used for Microsoft related OSs:

  1. Cygwin, which you can download it from the Cygwin official
    website at: https://cygwin.com/install.html

  2. MinGW, which you can download it from the MinGW official website
    at: http://www.mingw.org/wiki/Getting_Started

Any of these two compilers can compiler and run C++ codes on Microsoft-related operating systems.

Also if you install the Microsoft Visual Studio which is an IDE to write programs in multiple different languages including C++, it will automatically install a C++ compiler as well and so you can write and run C++ codes in this IDE too.

For those of you that use Unix-like operating system (Linux for example), there’s the GCC (GNU Compiler Collection) that can be used to compile and run C++ code.

First of all you need to check whether or not the compiler is already installed on your system.

To do that, open a terminal and type:

gcc –version

If you have the compiler on your system, you’ll get a message like the one below:

gcc (Ubuntu 7.2.0-18ubuntu2) 7.2.0

Copyright (C) 2017 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

But if you didn’t have the compiler on your system, open the terminal and type the command below to install the GCC complier:

sudo apt install build-essential

After the compiler is installed, if you rerun the gcc --version command, you’ll see the version of the compiler which means it is successfully installed on the computer.

For those of you that use Mac OS, you can also install GCC compiler on your computer by installing XCode which is an IDE for programming in multiple different languages including C++.

Check the link below to see how to install and run a C++ compiler.

https://discussions.apple.com/thread/5250041?answerId=22771361022#22771361022

Of course now that we have a compiler ready to compile and run C++ programs, we need a way to write C++ codes in the first place.

This is done via the help of IDEs which is explained in the next section.