Compiling C programs on Linux

Written by
Date: 2014-09-06 15:10:20 00:00


How to Compile and Run C programs on Linux

Q. How can you compile and execute C programs on Debian or Ubuntu Linux distributions

A. If you are a developer that happens to be using Linux now, you will notice that it is as easy as on Mac OS X or Windows to run programs written in C.

If you are using a Debian derivative, such as Ubuntu or Mint you need build-essensials package, so to install it just run:

apt-get install build-essential

Now you just need to write your first program.

/* Hello World program */

#include<stdio.h>

main()
{
 	   printf("Hello World");
}

Then compile it:

g++ hello-world.c -o hello-world

And run it:

./hello-world