Install g++ (Ubuntu) or gcc-c++ (RedHat or fedora) package using
apt-get or yum.
sudo apt-get install g++
or
yum install gcc-c++
Write a C++ program using your favorite editor.
emacs hello_world.cpp
or
vi hello_world.cpp
or
gedit hello_world.cpp
#include <iostream>
using namespace std; int main() { cout << "Hello World!\n"; return 0; }
The following command will compile your program
and create an executable called a.out
g++ hello_world.cpp
The following command will execute your program.
./a.out
how to run a grahpics program of c++ in linux
ReplyDeleteif u change the output file from a.out then use
ReplyDeleteg++ filename.cpp -o newname
now u'll get a compiled file named newname
u can execute is by running the following command
./newname
thnx nikita...4 a nice trick.. :))
ReplyDelete