Open In App

Types of C files after its compilation

Last Updated : 08 Jul, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

After writing C program when we compile and execute our program, there are various types of files are created. You can refer through Compiling a C program:- Behind the Scenes and How does a C program executes? for better understanding. 

Below are the points followed when every C file is compiled: 
 

  1. Every .h header file pre-compiles with it’s corresponding .c file and creates a header object file(.o file).
  2. Before compiling our main.c file it first go through the pre-processor, then compiler compiles it into assembler and creates object file (main.o).
  3. Then linker link the main.o with required header objects and libraries and creates a executable file (program.exe).

 

  1. Source file(.c): These files contain function definitions, and the entire program logics, these files are human readable and by convention their names end with .c .
  2. Header file(.h): These files contain function prototypes and various pre-processor statements. They are used to allow source code files to access externally-defined functions and by convention their names end with .h.
  3. Object file(.o): These files are produced as the output of the compiler. They consist of function definitions in binary form, but they are not executable by themselves and by convention their names end with .o.
  4. Binary executables file(.exe): These files are produced as the output of a program called a “linker“. The linker links together a number of object files to produce a binary file that can be directly executed. It contains symbols that the linker can extract from the archive and insert into an executable as it is being built. And by convention their names end with .exe in windows.
  5. Dynamic Library file(.so, .dylib, .dll): A dynamic library (.so files for most POSIX systems, .dylib for OSX and .dll files for Windows) is dynamically linked at runtime by the program. These are also sometimes referred to as shared libraries because one library image can be shared by many programs. Dynamic libraries have the advantage of taking up less disk space if more than one application is using the library. Also, they allow library updates (bug fixes) without having to rebuild executables. And by convention .dll is used for their naming in windows, and .so is used in MacBook and .dylib is used in OSX.

 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads