Compilation and execution in C Programming

Compilation and execution



Compilation and execution 

  • There are many steps involved in converting a C program into an executable form, these all steps are called "build process".
  • Build process are representing in the following graphically diagram : 
            
            C Source code Programs(assume file name first.c)

                   Expanded source code(first.i)

                      Assembly code(first.asm)


     Relocatable Object code + Object code of library function

                     
                 Executable code(first.exe)
Figure : Build process


If you don't understand the build process, don't worry,read following explanations of build process i.e. how a source program make executable program. It is all internal process of machine,that's done in neno seconds.


Lets now understand the steps mentioned in above figure in detail.
  1. Editor-Type your program in editor(source code).
  2. Preprocessing-During this step, the C source code is expanded based on the preprocessor directives like as #include#ifdef#define etc. The expanded source code is stored in an intermediate file with .i extension.
  3. Compilation- The expanded source code is then passed to the compiler, which identifies the syntax error in the expanded source code. If the expanded source code is error free, then the compiler transfer the expanded source code in C, into an equivalent assembly language program. The assembly code is typically stored in .ASM file. So our first.c file would be changed and stored in first.ASM.
  4. Assembling - Assembler translate the .ASM program into Relocatable Object code. Thus assembler translate our first.asm file into first.OBJ. .OBJ file is one of the binary file. This object file contained header and several section.
  5. Linking - Linking is the final step of build process i.e. creating an executable program. It's do following works :
    • Find definition of all external function
    • Find definition of all global variables
    • Combine Data Section
    • Combine Code Section
  6. Loading - Once the .EXE file is created and stored on the disk,it is ready for execution. when we execute it, it is first brought from the disk into the memory (RAM) by an OS component called Program Loader.

Tags - C, C++, programming, C++ tutorials, C++ programming, C programming Tutorials, source code, programming quiz 
Previous
Next Post »