Compiling a shared lib means adding 'fpic', which can mean poor codegen if you don't handle your symbol visibility well. By default symbols are globally visible and the compiler must assume that at runtime you may do an LD_PRELOAD in order to hook into some functions, and to do that the functions need to be called indirectly rather than directly.
At the very least, add '-fvisibility-inlines-hidden'.