Okay so the post should probably renamed to: what does -fPIC do.
After searching a little bit I found out that when compiling a shared library in this case you have to specify -fPIC to allow position independent code PIC
Originally this issue came up because I tried to link a static library to a dynamic library. It is therefore important to also build the static library using -fPIC