Assuming that you are using gcc and Linux or any unix based environment
To create a Library of code you need to do the following:
(1) Create an INTERFACE to your library: mylib.h
(2) Create an IMPLEMENTATION of your library: mylib.c
(3) Create a LIBRARY OBJECT FILE that can be linked with programs that want to use our library code or create a SHARED OBJECT FILE from many .o files that can be linked with programs that want to use your library code
gcc -o mylib.o -c mylib.c
gcc -shared -o libmylib.so mylib.o (for .a -shared is not required)
(4) USE the library in other C code: (a) #include "mylib.h" (b) link in the libary code into binary file
(5) Set LD_LIBRARY_PATH
environment variable for finding shared objects in non-standard locations at runtime.
If you still any have any query please feel free to comment...