NwabuezeFranklin / team

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0x09. C - Static libraries

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.

Tasks

0. A library is not a luxury but one of the necessities of life

  • libmy.a - a static library containing all the functions listed in main.h
    • Steps to Complete This Task

    • 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

1. Without libraries what have we? We have no past and no future

  • 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.

About


Languages

Language:C 100.0%