Difference between Header file and Library

Server Side ProgrammingProgrammingSoftware & Coding

In programming of any language such as C,C#,Java or any other programming language both header file and library combines and provide some specific API and its functionality to be used or consumed in the main file. So both header file and library are combined and used as single unit and we can't differentiate between both as these are not in the same context.

But on the basis of files nature we can distinguish between Header File and Library as follows −

Sr. No.KeyHeader fileLibrary
1DefinitionHeader File is the file where all the headers name are mentioned that going to be used or consumed in the main code file.On other hand Library is the file where the implementation code of each header is written down which is mentioned in the Header file.
2File ExtensionWith the resemblance of its name Header file have the extension of .h.On other hand Library file have the extension of .lib.
3File NatureAs already mentioned Header file have only header name i.e., it have the function declaration only.On other hand in case of Library file it have the implementation code of the header i.e., it has the actual function definition which is declared in the Header file.
4File LocationHeader files are available inside include sub directory which itself is in Turbo compiler.On other hand Library files are available inside lib sub directory which also itself is in Turbo compiler.
5File FormatAs Header file only have header name so are human readable as they are in the form of source code.On other hand Library files have actual implementation code so are non human readable as they are in the form of machine code.
Updated on 09-Jun-2020 07:53:27