You are on page 1of 2

How to compile your program

Compilation is a process of converting a program from source code to machine


code.

program.c =====> Compiler =====> Machine Code(0s & 1s)

(source code) (Executable Code/binary file)

C-Compilers :

GCC (GNU Compiler Collection) for linux/unix flavored OS.

MinGW compiler for windows platform.

Turbo C/C++

We will be using gcc compiler because it is updated and follows C-Standards.

Compilation of Program(Source Code) on Linux based OS :

$ gcc -Wall program.c -o program

program.c : source code of your program

program : executable file which will be loaded in memory(RAM) by loader

-Wall : turns on all the most commonly used compiler warning. (Optional)

Note : $ gcc program.c will give you executable a.out with no warning even if you
have warnings

Execute/Run Compiled Program :

$ ./program

./ : refers to the current directory

./program : Two step process happen Loading + Executing


1. Loading : Loads the executable file program located in current directory in
memory(RAM).

2. Executing : Executes the program meaning causes the CPU to begin


executing the instruction.

You might also like