I need little clarification in this area. I feel that the terms Static library
& Dynamic Library
are not correct.
Let's say I have my App that links with StaticLib.lib, then all the code from both my App and StaticLib.lib will be in the same executable. This means that StaticLib.h contains functions implementation in it.
Now if I link App with DynamicLib.lib, then my App will use functions implemented in DynamicLib.dll that means that DynamicLib.lib constains references, something like:
The name dynamic means that it can be loaded by any App, not really by linking with DynamicLib.lib, but calling LoadLibrary () and importing the functions exported by the DLL by hand.
About Relocatable, well at this moment I'm not familiar with the word.
I'm talking as a Windows programmer so I don't what really is going on on Linux, but judging from the name SO(Shared Objects) are same thing like DLLs.
Hope my answer was helpful!
.o
files are not any kind of library file. They are an object file.
.a
/.lib
files are linked at build time. They cannot be replaced after the fact. This makes them static.
.so
/.dll
files are linked at runtime. They can be replaced any time before execution starts. This makes them dynamic.
Relocation refers to placement of a binary in memory; code from static libraries is integrated with the binary and so can't be relocated independently.
Static libraries contain code that is copied into the executable. Code in the library that isn't referenced by your program is removed. A program with only static libraries doesn't have any dependencies during runtime.
Dynamic libraries are linked during runtime -- a program with references to a dynamic library will load and link with the library when it starts up (or on demand).
A Relocatable library is another word for a dynamic library. When you link with a dynamic library, the addresses of the functions contained within are computed, based on where the library is loaded in memory. They are "relocatable" because the addresses of the contained functions are not determined at link time. (In a static library, the addresses are computed during link time.)
An object file (.o) contains compiled code, but doesn't contain the final addresses of all of the functions. Linking is the process where the linker goes through all of the object files and computes the correct address for each function that is called.