Saturday, January 19, 2013

C++ with g++ in ubuntu

This post will pay attention on using g++ in ubuntu. (which is a very basic thing :))

$ sudo apt-get install build-essential


Create the C++ file. Let’s call the c++ file – “HelloWorld.cpp”.


#include <iostream>

using namespace std;

int main()
{
   cout << "Hello g++ \n";
   return 0;
}

Next use the following

g++ HelloWorld.cpp -o HelloWorld

An executable HelloWorld is produced and ready to be executed by using the following command.

 ./HelloWorld

You will see the output "Hello g++"




No comments:

Post a Comment