Installing C++ Compiler and IDE

Computer can’t directly understand the program that we write in C++ language. Compiler converts the program into machine language that is understand by the computer.

As we already know C++ is a compiled language. This means that every source file needs to be converted into an intermediate code called the object code with the help of a proper compiler and then linked with the other required object files to make an executable. You can see this below, to know how the source is processed to produce the output.

Installing C++ Compiler and IDE

Image Source

So, first we need a standard C++ compiler. To prepare source code, you may also need a professional text editor that offers auto complete and many more useful features. Instead of installing two programs separately, we may use an IDE (Integrated Development Environment) such as Dev-C++, Turbo C++, Codeblocks, etc.

Installing C++ Compiler and IDE

For Windows

For windows there are various options like Dev C++, Codeblocks, etc. You can download them from below link and then install.

http://www.thecrazyprogrammer.com/downloads

 

For Linux

If you are using a Linux or UNIX based system, mostly you don’t have to worry about the compiler installation. Linux and UNIX systems have built in C++ compiler called GNU C/C++ compiler.

You can check the version of the GNU C++ compiler in your terminal using ‘g++ -v’ command. If it is not installed, you can download one from below link.

http://gcc.gnu.org/install/

 

For Mac

The simplest and best way you can get the compiler for Mac computer is at xcode development tools. Just follow below link.

https://developer.apple.com/xcode/

 

How to Save and Run C++ Program?

1. Write your source code in the editor.
2. Save the file using .cpp extension.
3. Then compile the file.

Compiling the file differs on the compiler you are using. If you prefer to work with Dev C++, simply pressing F9 key does the task of compilation and F10 key runs the program. If it is a Turbo C++ compiler, use alt+F9 to get the source code compiled and ctrl+F9 to run the compiled code. One thing to note here is that if you have installed the turbo C++ compiler using DOS Box, the commands may differ slightly.

For Linux systems, here is the procedure.

1. Edit the source code with a built in editor like gedit or vi editor.
2. Then save the file with .cpp extension.
3. To compile it, use the below command.

g++ -o [objectfilename]  [sourcefilename].cpp 

This produces an executable named as given the object file name which can be run using ‘./objectfilename’

Eg:
g++ -o hello helloworld.cpp
./hello


If you are getting any difficulty to download and install C++ compiler then you can ask your queries by commenting below. I will try to solve your problem.

One thought on “Installing C++ Compiler and IDE

  1. arul

    hi,

    trying to work on dev c++ 5.4.0 ver(windows 8.1 32 bit). getting: error launch program(216) can anyone help
    thanks in advance.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *