In this tutorial you will learn about the C++ Installation and its application with practical example.
C++ Installation
Installing C++ In Windows
In order to set up a C++ Programming environment you need to have C++ Compiler installed on your system, so if you don’t have it installed, check the following instruction to get C++ installation. If you’ve already have installed C++ in your system, you can skip this part.
Step 1:- Download the turbo C++ online from any of the safe websites or directly from the link given below –
Step 2:- Create a folder “turbo” in c:\ Drive and extract the tc3.zip file in c:\turboc directory.
Step 3:- Now, start the installation by double-clicking the INSTALL Application file in the c:\turboc directory.
Step 4:- Follow the installation wizard to install Turbo C++. Press “Enter” here to start the installation.
Step 5:- Now, change or select installation directory to c:\ and press “Enter”
Step 6:- Now, select the c:\turboc directory that we have created containing required installation files, and press “Enter”
Step 7:- Now, select Start Installation using the down arrow key and then press “Enter”.
Step 8:- Installation is done, press enters to read the documentation and close the installation wizard.
Step 9:- Now you can begin writing a c/c++ program by starting the tc application located in c:\TC\BIN directory. This will application window as below.
Installing C++ In Ubuntu/Linux
Here is how you can install C++ in Linux –
Step 1:- Open a terminal and use the following command to install the C++ compiler and essential tools –
If you are on Ubuntu and Debian use the following command
1 2 |
$ sudo apt-get update $ sudo apt-get install build-essential manpages-dev |
If you are on CentOS, Fedora and Redhat use the following command
1 |
# yum groupinstall 'Development Tools' |
Step 2:- Let’s verify the installation using the following command
1 |
gcc --version |
Compile and Run C++ Program In Ubuntu/Linux
Step 1:- Create a file using a text editor program of your choice and save it with the .cpp extension. The .cpp file extension is used to specify C++ file.
Example:-
hello.cpp
Step 2:- Now, switch to the directory where the file is located. And, issue the following command to compile the C++ program –
1 |
$ g++ program-file-name.cpp-o program-name |
Here, replace program-file-name. cpp with your c++ program file name and program-name with any name of your choice.
Example:-
1 |
$ g++ hello.cpp -o hello |
Step 3:- If there is no compilation error, an executable file is created and you can see the output using the following command
Example:-
1 |
$ ./hello |
Installing C++ In Mac OS
Download and Install Xcode development environment to use GNU C/C++ compiler from Apple’s official website. the link is given below –
1 |
https://developer.apple.com/technologies/tools/ |