All dynamically loaded modules (and anything statically linked into them) must be compiled with Position Independent Code.
In g++ the option for position independent code is
"-fPIC
".
I know of no good test for position independence in a
library. You may be able to observe the number of symbols that are
output from nm
. It seems like PIC code has a lot more
extraneous symbols.