DIFFERENCES BETWEEN STATIC AND DYNAMIC LIBRARIES

To create an executable of our code is necessary, the first step is compile, in this process generate three important phases.
- Preprocess
- Compile
- Linker
In this section, we talk about linker and how to work with the libraries. it is file contain a number of function or subroutines. In linker time it check each function to resolve any reference and when the program do a called of this function it can be used.
STATIC LIBRARY
It is a collection of objects files and inserted into the executable file. So, only the executable file is necessary to run the program in everywhere. however, increment its size.
CREATE A STATIC LIBRARY
- Create a header file with all functions



2. Create a object file of each function

3. Create static library

some times is necessary indexed when we add new function to header file
and comeback to step 3 and the argument -r replace existing or insert new file(s) into the archive.
4. Finally create an execute file

important points about static libraries:
- Are not relevant during run time
- each process is a copy of the code anda data
- Are connected at compile time
- to create static library do not need to create a new executable
DYNAMIC LIBRARIES
It library are not into executing file so, is necessary to execute with the library. The format of Shared file or dynamic file is “.so”. Is is created of the same way that the static file.
- REPEAT STEP (ONE) OF STATIC LIBRARY
- Create an file .so

3. Apply compile the program to create execute and apply ldd (List Dynamic Dependencies) is a UNIX utility that prints the shared libraries required by each program or shared library specified on the command line. if library is not , it need to be add to environment variable.

important points about static libraries:
- is into the program
- need create a new executable
- it is only code shared, data is specific to each process
- it need to add to environment variable