1. Static libraries are compiled into the program itself, shared libraries are compiled separately and referenced by the program. This enables the program to be much smaller, but requires the shared libraries be available to run.

  2. The suffix of Static libraries file is ‘.a’, while Shared libraries is ‘.so’.

  3. When the executable file is started its loader function must find the shared library in order to load it into memory. By default the loader searches for shared libraries only in a predefined set of system directories, such as ‘/usr/local/lib’ and ‘/usr/lib’. If the library is not located in one of these directories it must be added to the load path.The simplest way to set the load path is through the environment variable LD_LIBRARY_PATH

  4. How to Create library file: Static library: » gcc -Wall -c buddy2/buddy2.c -o obj/buddy2.o         » ar csr stclib/libbuddy2.a obj/buddy2.o Shared library: » gcc -Wall -c -fPIC buddy2/buddy2.c -o obj/buddy2.o         » gcc -Wall -shared -o shrlib/ obj/buddy2.o

  5. How to link library : Static library: » gcc -Wall _-static -o buddy_stc buddy_test.o -lbuddy2_ Shared library:  » gcc -Wall -o buddy_shr buddy_test.o

GCC Command Options Desc:

 -Wl,option Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas.  -static On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.  -Wall This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros.

Reference: How to create static library and shared library: Shared libraries and static libraries: GCC link options: GCC Warning options: