I\'d like to build both static and shared libraries in a project.
I know that shared libraries need to be be created from objects compiled with -fpi
The common approach that I've seen is, in fact, compiling your source twice, once with PIC and once without. If you don't do that, you either wind up with PIC overhead in the static library, or a shared object that can't be relocated by the OS (effectively meaning it's NOT shared across multiple clients of the library).