ADVERTISEMENT
ADVERTISEMENT

Home » Latest Articles

Execution process of a C/C++ program

Pre-processing, Compiling, Linking, Loading

Execution of a C/C++ program involves four stages using different compiling/execution tool, these tools are set of programs which help to complete the C/C++ program's execution process.

  1. Preprocessor
  2. Compiler
  3. Linker
  4. Loader

These tools make the program running.

1) Preprocessor

This is the first stage of any C/C++ program execution process; in this stage Preprocessor processes the program before compilation. Preprocessor include header files, expand the Macros.

2) Complier

This is the second stage of any C/C++ program execution process, in this stage generated output file after preprocessing ( with source code) will be passed to the compiler for compilation. Complier will compile the program, checks the errors and generates the object file (this object file contains assembly code).

3) Linker

This is the third stage of any C/C++ program execution process, in this stage Linker links the more than one object files or libraries and generates the executable file.

4) Loader

This is the fourth or final stage of any C/C++ program execution process, in this stage Loader loads the executable file into the main/primary memory. And program run.

Different files during the process of execution

Suppose, you save a C program with prg1.c – here .c is the extension of C code, prg1.c file contains the program (source code of a C program). Preprocessor reads the file and generates the prg1.i (prg1.ii – for c++ source code) file, this file contains the preprocessed code.
Compiler reads the prg1.i file and further converts into assembly code and generates prg1.s and then finally generates object code in prg1.o file.
Linker reads prg1.o file and links the other assembly/object code or library files and generates executable file named prg1.exe.
Loader loads the prg1.exe file into the main/primary memory and finally program run.
One more file is created that contains the source code named prg1.bak; it’s a backup file of the program files.

Execution of a C/C++ program
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.