In this project, I learned the use of static library in C, and the difference betwween static and dynamic libraries. Basically, I learned the use of ar
, ranlib
and nm
commands.
- libmy.a - a static library containing all the functions listed in main.h
- To copy the c-files from other directory to working directory, e.g. 0x09-static_libraries, do:
cp ../0x04-more_functions_nested_loops/0-isupper.c 0-isupper.c
- To compile your c-files into object files, do:
gcc -Wall -Werror -Wextra -pedantic -c *.c
- To create the static library (
libmy.a
) and stored the object files in it, do:ar -cr libmy.a *.o
- To see the object files stored in
libmy.a
, do:ar -t libmy.a
- To see the symbols used in the library, do:
nm libmy.a
- To create an executable file, quote from main.c using the library,
libmy.c
, do:gcc -std=gnu89 main.c -L. -lmy -o quote
- create_static_lib.sh - a script that creates a static library called liball.a from all the
.c
files that are in the current directory.