, -shared no-op ( , ), . info gcc :
'-shared'
Produce a shared object which can then be linked with other
objects to form an executable. Not all systems support this
option. For predictable results, you must also specify the same
set of options that were used to generate code ('-fpic', '-fPIC',
or model suboptions) when you specify this option.(1)
... :
(1) On some systems, 'gcc -shared' needs to build supplementary stub
code for constructors to work. On multi-libbed systems, 'gcc -shared'
must select the correct support libraries to link against. Failing to
supply the correct flags may lead to subtle defects. Supplying them in
cases where they are not necessary is innocuous.