José Abell's research blog

NTS (Note-To-Self): Creating dynamically linked libraries

A nice extensive tutorial can be found here.

In a nutshell:

gcc -Wall -fPIC -c \*.c  
gcc -shared -Wl,-soname, -o \*.o  
mv /opt/lib  
ln -sf /opt/lib/ /opt/lib/  
ln -sf /opt/lib/ /opt/lib/
  • -Wall: include warnings. See man page for warnings specified.
  • -fPIC: Compiler directive to output position independent code, a characteristic required by shared libraries. Also see “-fpic”.
  • -shared: Produce a shared object which can then be linked with other objects …