Creating Libraries
Assume you want to create a library that supports linked lists.
Using the .c and .h files you wrote for defining a linked list and operations on a list, you compile them separately and then archive them into a library:% gcc -c -o link.o link.c% gcc -c -o list.o list.c% ar q mylistlib.a link.o list.o% ranlib mylistlib.aNote: use “ar ruv” when library already exists.
To use any of the functions in the .c files, include the appropriate header file and link mylist.a as follows:% gcc myprog.c mylistlib.a