0% found this document useful (0 votes)
69 views2 pages

How To Compile Your Program: C-Compilers

This document discusses how to compile a C program on Linux. It explains that compilation converts source code into machine code by using a compiler like GCC. It provides steps to compile a C program called program.c into an executable program file using the gcc compiler command with options to generate warnings and output the executable as program. It also explains how to execute the compiled program by running the ./program command.

Uploaded by

Sanjeev Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views2 pages

How To Compile Your Program: C-Compilers

This document discusses how to compile a C program on Linux. It explains that compilation converts source code into machine code by using a compiler like GCC. It provides steps to compile a C program called program.c into an executable program file using the gcc compiler command with options to generate warnings and output the executable as program. It also explains how to execute the compiled program by running the ./program command.

Uploaded by

Sanjeev Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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