views:

54

answers:

3

Hi I wanted to know in depth meaning and working of compiler, linker and loader. With reference to any language preferably c++.

thanks in advance !

+2  A: 

Try looking at this

Terrance
+1  A: 

Wikipedia ought to have a good answer, here's my thoughts:

  • Compiler: reads something.c source, writes something.o object.
  • Linker: joins several *.o files into an executable program.
  • Loader: code that loads an executable into memory and starts it running.
RedGrittyBrick
+1  A: 
  • A compiler reads, analyses and translates code into either an object file or a list of error messages.
  • A linker combines one or more object files and possible some library code into either some executable, some library or a list of error messages.
  • A loader reads the executable code into memory, does some address translation and tries to run the program resulting in a running program or an error message (or both).

ASCII representation:

[Source Code] ---> Compiler ---> [Object code] --*
                                                 |
[Source Code] ---> Compiler ---> [Object code] --*--> Linker --> [Executable] ---> Loader 
                                                 |                                    |
[Source Code] ---> Compiler ---> [Object code] --*                                    |
                                                 |                                    |
                                 [Library file]--*                                    V
                                                                       [Running Executable in Memory]
Gamecat