Types of C files after its compilation

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).
    Here is the list of files that are created:
  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 .c.
  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 .c.
  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.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :