how does compiler work to execute c program


Joined Jun 6, 2011
A basic process of compiler is that we write code in text editor and we check the error in the program then compiler generate execrable file

anybody knows how linker and loader work in compiler
A linker and loader do not work in a compiler.

They are separate programs in the tool chain:

Source code -> Compiler -> Object code
Object code -> Linker -> Executable
Executable -> Loader -> Running Program


Joined Apr 24, 2011
To expand on joey's correct answer, a compiler outputs object code. The reason for this is an object is a mostly filled in image of the code to run, but it has some blanks to fill in. This is so other objects can also be included into the final executable. These would be say other c files your project uses, or library objects your source called out that need not be compiled just have their objects copied and pasted in.

Once all the objects are created or found the linker can assemble them into the exeacutable and fill in the blanks, which are items such as the address of variables or function.


Joined Oct 2, 2009
Generally, we reserve the word compiler to refer to a program that converts code written in text to machine executable code that can run only on a given target processor.

Not all "compilers" are true compilers. There are languages and various implementations of languages that never compile the code. Some implementations are known as interpreters. Other implementations will use an intermediate code called p-code, short for pseudo code or portable code.

Java is an example of a "compiler" that uses the Java Virtual Machine to execute bytecode instructions that can run on any machine.