I am brand new to C programming (but not programming) and am trying to understand how libraries and header files work together, particularly with respect to packaging and distribution.
After reading this excellent question and its answer, I understand that the header file(s) act as the API to a library, exposing capabilities to the outside world; and that the library itself is the implementation of those capabilities.
However one thing that I cannot seem to find a good explanation of is: how are header files packaged into or distributed with the libraries?
- Are the libs and their headers packaged into an archive (zip, tarball, etc.)?
- Are headers compiled into libs and distributed alongside them?
When I do a #include "mylib.h"
, how does the linker know where to find:
- the header file itself,
mylib.h
- the library implementing the functions declared in
mylib.h
.