What is compiler, linker, loader?

后端 未结 14 953
离开以前
离开以前 2020-12-07 06:48

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

相关标签:
14条回答
  • 2020-12-07 07:17

    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.
    0 讨论(0)
  • 2020-12-07 07:18

    Hope this helps you a little more.

    First, go through this diagram:

                             (img source->internet)
    

    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.

    0 讨论(0)
  • 2020-12-07 07:19

    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

    0 讨论(0)
  • 2020-12-07 07:20

    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

    0 讨论(0)
  • 2020-12-07 07:22
    • Compiler : Which convert Human understandable format into machine understandable format
    • Linker : Which convert machine understandable format into Operating system understandable format
    • Loader : is entity which actually load and runs the program into RAM

    Linker & Interpreter are mutually exclusive Interpreter getting code line by line and execute line by line.

    0 讨论(0)
  • 2020-12-07 07:23

    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.

    0 讨论(0)
提交回复
热议问题