SUPPORT THE SITE WITH A CLICK

Subscribe Rss:

SUPPORT THE SITE WITH A CLICK

Friday, January 18, 2008

Compile/Run C++ in Linux

For running c++/cpp programs in linux,first we have to check g++ is installed in the system or not.
Open the linux terminal and type g++ -v,this will shows the version of g++ in your system.
Now write your c++ program in linux terminal by opening with vieditor.
For example vim a.cpp
Now write your c++ program and sabe it as a.cpp

sample c++ program
#include

using namespace std;

int main()
{
cout << "Hello World!" << endl;
return 0;
}

now in the terminal type g++ -o a a.ccp.In your machine a file with name a will be created.
now in the terminal type ./a .It will display the Out put of your c++ program

root@aspx-desktop:~# vi 1.cpp
root@aspx-desktop:~# g++ -o 1 1.cpp
root@aspx-desktop:~# ./1
Hello World!
root@aspx-desktop:~#

No comments :

Post a Comment