C++ Programming Environment Setup:
A C++ Program can be either run locally on your computer or in any online platform who provides Online C++ compilers. In this tutorial you will learn how you can run a C++ program locally on your computer and also will we give you some online site reference where you can run a basic C++ Program.
C++ Programming Environment Setup on Computer
There are various open source application as well as some paid application on which you can write, edit , compile & run your C++ Program. To run a C++ Program on your computer two application are required –
- Text Editor: To create and edit a C++ program. Examples of few text editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS etc.
- Compiler: To compile and execute a C++ program. The most frequently used and free available compiler is the GNU C/C++ compiler,
You can install and use various application on your computer to run a C++ program depending on your Operating System (OS) that you have in your computer. Below are the list of some famous and commonly use text editor and compiler for various Operating System.
C++ Programming Environment Setup on Windows Operating System
There are plenty of free as well as paid C++ compilers are available for Windows platform. Some of the most commonly used C++ compilers for Windows platform are Turbo C++, Visual Studio C++, Dev C++, Code::Blocks etc. Where you can use Turbo C++, Dev C++ and Code::Blocks for free but you need to buy a license for Visual Studio.
You can use any one among Turbo C++, Dev C++ and Code::Blocks as these provides almost all the functionality of C++ compilers. Below are the official links for download these applications. All the installation process are clearly mention on their respective official website. You can follow that.
- Turbo C++: Click here
- Dev C++: Click here
- Code::Blocks: Click here (Under Windows XP / Vista / 7 / 8.x / 10 section, click the link with mingw-setup highlighted row either from Sourceforge.net or FossHub.)
Our recommendation: We personally use Code::Blocks and Visual Studio for complex program. In our tutorials we will use Code::Block as it is free, so that our readers doesn’t face any problem.
C++ Programming Environment Setup on Linux Operating System
To create and run a C++ program on Linux OS , you need the following application-
- Compiler: We’ll install GNU GCC compiler which is most commonly use and good for beginners.
- Development tools and libraries.
- Text editor: Preinstalled gEdit works just fine in our case. Or, you can download any text editor of your choice.
Here’s a step by step guide to run C++ in Linux based OS like Ubuntu, Debian, CentOS, Fedora, Redhat etc Scientific Linux :
Open the terminal and type the following commands.
For Ubuntu and Debian distribution:
$ sudo apt-get update
$ sudo apt-get install build-essential manpages-dev
For CentOS, Fedora, Redhat and Scientific Linux:
# yum groupinstall ‘Development Tools’
This installs GNU GCC compiler and related required tools on your system. You can verify if GCC compiler is installed successfully or nor, type the following command on terminal.
$ gcc –version
If you get output similar like this, gcc is correctly installed on your system, it means you are good to go.
Open the text editor of your choice, type your C++ code in it and save it with .cpp file extension. I made myFirstProgram.cpp file using gEdit. Then Switch to the directory where the file is located. And, issue the following command.
$ g++ myFirstProgram.cpp-o name-of-your-choice
Here, myFirstProgram.cpp is the filename of the source code . And, name-of-your-choice can be any name you prefer. In my case, I issued the following command.
$ g++ myFirstProgram.cpp -o myFirstProgram
If there is no error, an executable file named is created; myFirstProgram is my case. Finally, you can see the output using following command.
Here, put name-of-your-choice field of you program instead of myFirstProgram. Also, you need to use path to the execute file if you are in a different directory.
C++ Programming Environment Setup MAC Operating System
If you have a MAC, XCode is the best application for you to create and run a C++ program. You can download the application from their official website.
Download XCode from apple developer site: click here
All the process for installing XCode on your device, the tutorials are available on their official website. You can follow them.
Run C++ Program Online
A C++ program can be run locally on computer as well as it can be run Online also. Many online platform provide C++ compiler where you can easily write and run your C++ Program. Two of such platform are onlinegdb.com and ideone.com.
But we recommend you to write and execute your C++ Program locally on your computer. As, it take less time to compile and execute the code as compared to online platform. And some complex functionality does not provide by any online platform. Also you can easily store the source code from it onto your computer for future reference.