Compiling C programs requires you to work with five kinds of files:
.cby convention. Note:
.cppare C++ files; not C files.
.oby convention, although on some operating systems (e.g. Windows, MS-DOS), they often end in
main()function in a library). A library contains functions that may be used by more than one program. A library should ship with header files which contain prototypes for all functions in the library; these header files should be referenced (e.g;
#include <library.h>) in any source file that uses the library. The linker then needs to be referred to the library so the program can successfully compiled. There are two types of libraries: static and dynamic.
.afiles for POSIX systems and
.libfiles for Windows — not to be confused with DLL import library files, which also use the
.libextension) is statically built into the program . Static libraries have the advantage that the program knows exactly which version of a library is used. On the other hand, the sizes of executables are bigger as all used library functions are included.
.sofiles for most POSIX systems,
.dylibfor OSX and
.dllfiles 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.