`-shared' Produce a shared object which canthen be linked with other
objects to form an executable. Not all systems support this
option. For predictable results, you must also specify thesame
set of options that were used togenerate code (`-fpic', `-fPIC',
or model suboptions) when youspecify this option.(1)
gcc manul上面有说
-fpic If the GOT size for the linkedexecutable exceeds a machine-specific maximum size, you get an error messagefrom the linker indicating that -fpic does not work; in that case, recompilewith -fPIC instead. (These maximums are 8k on the SPARC and 32k
on the m68k andRS/6000. The 386 has no such limit.)
-fPIC If supported for the targetmachine, emit position-independent code, suitable for dynamic linking andavoiding any limit on the size of the global offset table. This option makes adifference on the m68k, PowerPC and SPARC. Position-independent code
requiresspecial support, and therefore works only on certain machines.