A static library is an archive file containing object files that remain static until the program is recompiled.
- Using a static library only one object file needs to be pulled in during the linking phase. The benefit is that the functions and other symbols loaded into it are indexed and linking a program whose objects files are ordered in libraries is faster than linking files separate on the disk.
- Include all function prototypes of .c files into the header file
- Compile .c files with gcc -c command
- Create an archive file (static library) with files .o and the command used is ar -rc filename *.o ( "ar" creating and mantaining libraries, "-r" replace or add files, "-c" create a new file and "*.o" is the selection of all object files.
- "gcc" command to compile C files, "-L" tell the linker that the libraries be found in the current directory, "-l" links the C file with the library file, "example" name of the static library, "-o" change the name of the executable file.
I hope i could have helped you understand a little about Static libraries.
Stay tuned!
Danielle Serafim.
Senior Software Developer in Test
3yExcellent description of the process.