I wanted to know in depth meaning and working of compiler, linker and loader. With reference to any language preferably c++.
Wikipedia ought to have a good answer, here's my thoughts:
Hope this helps you a little more.
First, go through this diagram:
(img source->internet)
You make a piece of code and save the file (Source code), then
Preprocessing :- As the name suggests, it's not part of compilation. They instruct the compiler to do required pre-processing before the actual compilation. You can call this phase Text Substitution or interpreting special preprocessor directives denoted by #.
Compilation :- Compilation is a process in which a program written in one language get translated into another targeted language. If there is some errors, the compiler will detect them and report it.
Assemble :- Assemble code gets translated into machine code. You can call assembler a special type of complier.
Linking:- If these piece of code needs some other source file to be linked, linker link them to make it a executable file.
There are many process that happens after it. Yes, you guessed it right here comes the role of the loader:
Loader:- It loads the executable code into memory; program and data stack are created, register gets initialized.
Little Extra info :- http://www.geeksforgeeks.org/memory-layout-of-c-program/ , you can see the memory layout over there.
A compiler is a special program that processes statements written in a particular programming language and turns them into machine language or "code" that a computer's processor uses
compiler changes checks your source code for errors and changes it into object code.this is the code that operating system runs.
You often don't write a whole program in single file so linker links all your object code files.
your program wont get executed unless it is in main memory
Linker & Interpreter are mutually exclusive Interpreter getting code line by line and execute line by line.
Compiler It converts the source code into the object code.
Linker It combines the multiple object files into a single executable program file.
Loader It loads the executable file into main memory.