Quote:
Originally Posted by x96riley3
When using a static library, the linker finds the bits that the program modules need, and physically copies them into the executable output file that it generates. For shared libraries, it doesn't --- instead it leaves a note in the output saying `when this program is run, it will first have to load this library'. Obviously shared libraries tend to make for smaller executables; they also use less memory and mean that less disk space is used.
With something like stdio, a single shared library serves all of the programs to use printf, getc, etc; and yes, that saves a lot of memory. But now consider a single program that needs, say, a square root function. With archive libraries, we can the square root function out of the math library and build the program. With shared libraries, we must load the entire shared library into memory. Routines like log(), cos(), atan2(), gamma(), etc get loaded whether you use them or not. This leads you down a different path and you design libraries differently. Instead of a math library, you really want algebra, trig, statistics, and calculus libraries. And rather than loading a library with features, you want them "lean and mean". With archive libraries, it was cool to have a hyperbolic cosine function. With shared libraries, I'm thinking "who needs those hyperbolic trig routines?" Libraries are now a place to put very commonly used routines. They are no longer collections of functions in a general sense.