Interested in Personalized Training with Job Assistance? Know More
Hello everyone, my name is Atharva and we are continuing with this C programming course….. in which in the last video we had discussed about running and debugging topics.
We had seen that when we make one C program after that when we are executing it, at that time, we have to face different types of errors.
So, what is the exact meaning of these errors and why do they occur? How can they be identified and then how can they be rectified? All these things we had discussed in our previous video and this rectifying process is called debugging.
After learning about running and debugging now comes the time, time to learn about another new topic which is called as compilation and execution.
Now, here what is the meaning of compilation and execution? We are going to understand in this video.
If we talk about our C program when we complete it and when we go towards compiling it, our compiler comes in the picture.
He compiles the entire program and tells us that according to him there is an error in the program or not.
If there is no error, he would completely compile it and then run our program.
So, this entire compilation process in this there are different parts through which our code or our program goes through.
And one by one the code written inside it gets converted in our machine language code or in any other form.
So, how it gets converted? Which all things come here in the picture about which we still don't know.
All these things we will be seeing in this video.
So, without any delay we will quickly start and first of all we will see our flow of the program, which means when we write a source code or when we write a program, what is the procedure that is followed after writing of the program that we would be discussing over here.
What would be the flow? That is what we'll be discussing over here.
As soon as we write our program and we save it and then we tell our compiler to now run the code.
As soon as we try to run or compile the code, first our program which we also call as the source code that goes to the preprocessor.
Now we know that in our program the preprocessor commands that are there, all those files we write which we have to include in our program.
Basically, those commands are read by our preprocessor.
And he gets to know that in this program these files are needed and they arrange it over there.
So, first of all, our program goes to the preprocessor.
And what it does there is what the files that we had written, this file has to include even this has to be included.
It brings them here and makes it readily available for us, which means the files that were there its entire code is expanded and given here.
After that when it expands the code, our include files.
After that it goes to our program compiler.
And what does the compiler do? Compiler first of all checks our code or our program.
Is there any error in that, which means that we have not created any error in the syntax.
All the logic is correct or not.
After checking all these things, our compiler converts it in assembly code.
This assembly code we'll be seeing it going ahead in this video.
But for now let's understand that the compiler converts it into assembly code.
And after that our assembler comes in the picture.
What does the assembler do? The assembly code that has been converted it takes it and completely converts it into machine level code, which we also called as object code.
And we all know that the language that the machine knows is of zeros and ones, so our assembler, he basically with the assembly language or code, it converts it.
In what? Into machine understandable language.
Now that it has got converted, everything is done.
It has got converted into machine language code.
After that our linker comes into the picture.
And pre-processors who had readily made this file available to us, which all files we had to include in our code, in our programme.
So, what is the job of a linker? All those files which are already there in object code, object code means our machine language code.
It joins it with our program.
It links it and that's why we call it as linker as well, when it links it after that it makes one executable file whose extension is usually .e x e.
Now how it will look? We will be seeing all these things.
But for now, let's understand that the linkers job is the files that we had asked to include, those file’s code and our program.
It links these two together and makes one executable file which is basically our main output of the program.
And that output basically runs in which we perform input and output operations or interaction with the terminal, all these things happen.
So, this is our flow.
When we talk about executing a program, all these steps are followed at the time of our program's execution.
Now we will understand the process one by one quickly again, if we talk about our preprocessor.
So, what is a preprocessor? It is one type of software.
In C programming language preprocessor’s work is that the things we had written on the top of the program with the help of preprocessor directives where we were telling through our program that these header files we have to include with our code.
So, the preprocessor identifies those commands and makes those code readily available.
So that the linker in the last step, link it with our code, that's why it makes it available over here, preprocessor.
What happens after that? We will read it once again over here.
“It takes the source code as an input”.
Source code means our program and removes all the comments from the source code, so here the comments that we had written which means as per our convenience, the comments that we had written by putting double forward slash, all those comments are also removed by the preprocessor because eventually they have to be ignored.
They are only for the user who has written the program.
It's for his understanding.
There is no connection with the execution.
That's why our preprocessor removes those comments, discards them and the things that we had written in preprocessor directives.
It interprets that file that this file is needed, studio.h file is needed, or any other file is needed.
So, it readies those files over here and keeps them.
After that all when all these processes are done.
After that, our program or code that goes into our compiler.
So first of all, it goes to the preprocessor.
And then the code comes to our compiler.
So, “compiler checks for any syntax errors in the source code”.
Now the things that we have written in that our compiler checks if there are any errors or not, like we had discussed, like if we are defining int, if we have written the int in capital, so our compiler will understand that here in the programme, we have made some mistake.
In the same way, the syntax errors are understood by our compiler, and it displays it for us but if those errors are not found by us, if the compiler doesn't get it in our program, then what does the compiler do? Then the compiler converts code provided by the preprocessor into assembly code.
In the assembly code our program which was there earlier, which had come from the preprocessor, it converts that into assembly code.
Now what is this assembly code? We know that what language does the machine understand? Of zeros and ones, which is a very basic language and the language that we write the program in, like here we are talking about the C language.
So, in the C language, we will see that we basically use English, we use English words, English letters.
So, this English and the zeros and ones language, while converting these languages, the code and language use in between is called as an assembly code.
So, first of all the program written by us gets converted into assembly code, which is a low-level language, which means we can understand it little bit but it is a very basic language, which means it is not like English or not like a C programming language.
We had seen that C programming language is higher level programming language.
But if we talk about our assembly code, assembly code is a code in between machine level code and high-level code.
That's why first of all program gets converted into assembly code and who does this conversion it is done by our compiler.
So, what does the compiler do? It checks the error.
If there is no error, then it converts it into assembly level code.
Now our program has been changed into assembly code.
Now comes our assembler in picture.
What is the job of the assembler? “It only converts the assembly code into machine level code”.
What is assembler? Assembler is also one type of software, what does it do? The assembly code that was generated by our compiler it converts them into the language of zeros and ones so that our machine understands that.
So, here machine means what are we talking about? We are talking about the CPU or our processor.
To convert the assembly code into machine understandable language or in machine understandable code, who does this work? Our assembler does this work.
So, we had started with preprocessor, then we saw compiler, then we saw assembler, and at the end comes our Linker.
When we had seen in the first step, the preprocessor reads all those files and makes them readily available.
Now they have come to us and they are already in the object code.
And what is the object code? Object code is machine understandable code.
Machine understandable code is also called as object code.
Now what has happened after going through the preprocessor, compiler, assembler, it gets converted into machine level code.
And along with that the files which were there like stdio.h file or we can see string.h file.
all these files are already there in machine level codes.
So, what does our linker do? It combines these two codes, so that it becomes one single file it combines them that's why it is called as Linker.
And after it links it makes one executable file.
So, “it is used to link the object code of included libraries and object code of our program”.
So, after adding these two, after linking them both it makes one file which we call as one executable file.
Now you must have seen that whenever we write our programs practically when we compile them .exe named file gets generated into the same folder in the same name.
Only its file extension is .exe, .exe is this executable file which our linker has made for us.
Now this executable file runs at the end.
So, at the end .c extension file doesn't run, it converts through the entire process and becomes an executable file and after that it basically runs.
So, this entire process of executing any program, compiling it.
The behind the scene picture, we have discussed it here.
Till now we were saying that our compiler does this, our compiler converts the program in this way.
But if we talk about, what do we want to denote by saying compiler.
So, here we want to denote the entire process in which preprocessor comes, compiler comes, assembler comes and even linker comes.
So, after completing this entire process, we get one executable file and that runs easily and whatever we want to do through the programme that gets completed over here.
So, this was about a compilation and execution process.
Now what we will do once is we will take any file and when we will run it you will see that there will be one executable file that will be made of the same name.
So, here you can see that our debug.c named file it doesn't have a .exe extension file.
But as soon as we will compile it over here, so to compile we will be using this command over here..
So, you can see it this debug,exe named executable file has been made over here.
So, this is the file which comes to us after the entire process is completed and this exe file is basically which runs.
So, this entire process of execution and compilation.
If you think that there is any part of this video or this topic, you might have not understood then you can ask us any query or question related to that topic without any inhibition.
You just have to go on forums.learnvern.com,
you have to type your query there in your own language and we will
come up with the solution or the answer as soon as possible in your own language.
Apart from this if you wish to have a discussion on any topic.
Even that you will be able to do on forums.learnvern.com.
Ahead of this we will be discussing few additional features which comes in C and we will be able to do few more advanced things with this and we will meet you in the next video where we will be discussing few more additional things, few more advanced topics till that time you keep practising C programming, thank you so much.
Have a friend to whom you would want to share this course?