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:
- Every .h header file pre-compiles with it’s corresponding .c file and creates a header object file(.o file).
- 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).
- 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:
- 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 .
- 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.
- 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.
- 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.
- 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.
- MCQ on Memory allocation and compilation process
- Linking Files having same variables with different data types in C
- Header files in C/C++ and its uses
- Difference between fundamental data types and derived data types
- Macros and its types in C/C++
- What’s difference between header files "stdio.h" and "stdlib.h" ?
- C Program to list all files and sub-directories in a directory
- C Program to merge contents of two files into a third file
- C program to compare two files and report mismatches
- Header files in C/C++ with Examples
- Relational Database from CSV Files in C
- C++ default constructor | Built-in types
- Introduction of Smart Pointers in C++ and It's Types
- How to print range of basic data types without any library function and constant in C?
- Extended Integral Types (Choosing the correct integer size in C/C++)
- What are the data types for which it is not possible to create an array?
- C | Data Types | Question 1
- C | Data Types | Question 2
- C | Data Types | Question 5
- C | Data Types | Question 6
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.