in Computers by

1 Answer

by (35 points)

A compiler is a translator converts high level language to machine language which it can be understood by the computer and perform tasks. The computer prefers only  binary language where as humans do not find the binary language very friendly. Hence, complier acts as a mediator to convert our simple instructions into binary instructions, that it can be understood by the computer. There are 3 stages of compilation in C++.

1st Stage :The simple instructions, or conditional files or macros  written by programmers which contains instructions that is to be performed by computer is pre-processed to form a source code.

2nd stage: This source code is converted into the assembler source code

3rd Stage :The assembler converts this assembler source code into assembly listing with offsets. This output is stored in an object file. This output is stored in an object file.

Linker is used to combine one or more object files or libraries into a single executable file. This process is called linking. Relocation is process done in doing linker to solves the operations present in the instructions, assigns addresses to the operations and variables and copies the code as well as data to new memory location .The  linker assembles the object files and moreover store them in secondary storage device such as hard disk as executable images. The object file can be either statically linked or dynamically linked.