hello this video I will explain
compliation process when we compile NEC
program what are the steps how your
compiler generated object file and how
it runs that files so we will see all
these steps in this lecture in this
video so first we will have a quick look
on the compiler components so compiler
is not a single module compiler is
having multiple modules so we can
categorize we can divide this compiler
into four big modules so these are the
preprocessor compiler assembler and
linker so preprocessor this is the first
step so when we write any C program so
that C program first process by
preprocessor and preprocessor generate
some intermediate file that files given
to compiler role of compiler is that
compiler convert files generated by
preprocessor as an input and generate a
assembly code so it convert our c
program files into the assembly language
now as we know computer can execute only
binary code means 0 one language
assembly for still it not understood by
our machine so we need a converter which
can convert this assembly code into the
machine code there is another module
this is known as assembler this this
assembler will convert this assembly
code into the object code now what is
the role of linker when we write our
program we use some libraries functions
so linker will link our object code with
those library code and generate it exe
files so here we will see these steps in
depth so first step pre-processors what
is the purpose of preprocessor so say
for example this is our program first
line this is a comment and then we
haven't already header file and this is
simple main function we are printing CIN
message hello so what preprocessor will
do first task preprocessor will remove
commands from the code so if you can see
the code will be removed by the
preprocessor so in the generated file
there is no comment second task P
processor does it will include header
file code in the file itself so if we
have included say stdio rotates this is
also a file so the code of that file
will be included in our program this is
the second task and the third task if we
are using any macro so P processor will
replace all the macro name by its value
so we can say P processor from three
tasks remove comments include header
files in source code and replace macro
name with the code so these are the
tasks of preprocessor so once P
processors is done with all these three
tasks
if files is generated in our case this
file is this one the next one is
compilers the role of compiler the
compiler will take this file and
generate a assembly code assembly code
there all the instructions defined by
English words these words actually known
as mnemonics so this is the generated
assembly code compiler generate this
code from this file now next step our
assembler so our assembler convert this
assembly code into the pure binary code
or machine language so that language is
your 0 1 1 0 language and this code also
known as object code
okay so assembler convert assembly code
into the object code now linker what is
the role of linker first
case we can consider if you are if sorry
you are working on a project and in your
project there are multiple modules and
one person working on one module so at
the end you people will be having a
number of C files C program files when
you compile them you will be getting
number of object files so at the end
what we want you want only a single
executable file so we have to combine we
have to merge all the object code into
that single one so one roll of linker is
this one another rule if we are using
some function from libraries so what
linker will do linker will link our code
with that library function code so there
are two type of linking static linking
or dynamic linking so it's up to the
linker what type of linking your linker
is using so here we are taking an
example say and there are multiple
object file object codes and these ports
actually using some function from the
library so what linker will do linker
will Club all these files take linked
with the libraries function pack
everything in a single file at that
final known as your on Windows platform
we can say that file is a dot exe file
on Ubuntu this file is generated with a
dot out action name so these are the
four steps pre-processors compiler
assembler and linker thank you very much