shared library

What is the primary difference between static library and dynamic library?
and how to write static shared library?

Static library is linked during compilation (.a-files), dynamic libraries are being linked by ld during execution (.so-files)
Check out http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/pdf/Program-Library-HOWTO.pdf