In this tutorial we will learn how to compile and run C++ program in Linux.
Now Compiling and Running C++ Program in Linux is so easy. Just follow few simple steps and you are done.
STEP 1: First install C++ Compiler:
[root@localhost ~]# yum install gcc-c++
STEP 2: Write and save the C++ Program using any editor.
Here I am using VI/VIM editor to write C++ Program.
[root@localhost ~]# vim linuxprogram.cpp
STEP3: Compile the Program.
[root@localhost ~]# c++ linuxprogram.cpp
STEP 4: Execute or Run the Program.
[root@localhost ~]# ./a.out .out
This my First Program in Linux
[root@localhost ~]#
ANOTHER METHOD TO COMPILE AND RUN C++ PROGRAM IS:
[root@localhost ~]# g++ linuxprogram.cpp -o linuxtiwary [root@localhost ~]# ./linuxtiwary This my First Program in Linux [root@localhost ~]#
Advertisements