Patch to work with static and shared libraries