How to install C and C++ Compilers in Ubuntu

Posted on the October 23rd, 2009 under Ubuntu by Stephen

Simply run:

sudo aptitude install build-essential

This will install cc (C) and g++ (C++) compilers and some others.


Examples:

Using the vi editor to open a file called hello.c:

vi hello.c

and type:

#include <stdio.h>

int main()
{
       printf("Hello world!\n");
       return 0;
}

Now compile the program:

gcc hello.c -o hello

A new file called “hello” should be created, run it using:

./hello

output:

Hello world!

Share this page:
  • Facebook
  • Twitter
  • StumbleUpon
  • Slashdot
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Live
  • MySpace
  • Technorati
  • LinkedIn
  • Reddit
Related Posts:
  1. How to Install Ubuntu 9.10 using VMware in Windows Vista
  2. How to add/remove Programs in Ubuntu
  3. How to install Google Chrome in Ubuntu 9.10
  4. How to Install Ubuntu 9.10
  5. How to install CURL?

Leave a Comment