Is the question also included 'how to create dynamic link library'? If so, this is answer.
To create share library or dynamic link library do as follow.
I also include description taking from 'man gcc' for time-saving too.
#gcc -c -fPIC mydev.c -o mydev.o
#gcc -shared libmydev.so mydev.o
Create executable file (linking with ddl)
#gcc mynewdev.c libmydev.so
Then when you take your program to run on other machines make sure you copy *.so file to /lib/ or /usr/lib too.
If supported for the target machine, emit position-independent
code, suitable for dynamic linking and avoiding any limit on the
size of the global offset table. This option makes a difference
on the m68k and the SPARC.
Position-independent code requires special support, and therefore
works only on certain machines.
I think you already know how to create static library but I will included to this post for another may find it useful.
Create static link library:
#gcc -c mydev.c -o mydev.o
#ar rcs libmydev.a mydev.o
Create executable file (linking with static):
#gcc -static mynewdev.c -lmydev