The C++ libraries are linked by default when building an executable program, but not when building a shared library (.so). When building a shared library, all needed libraries must be listed explicitly. The -zdefs option will cause the linker to complain if a needed library is omitted, and is the default when building an executable program. In default -compat=5 mode, the following libraries are linked by default by the CC driver:
In -std=c++03 and -std=c++11 modes, the following libraries are linked by default by the CC driver:
-lstdc++ -lgcc_s -lCrunG3 -lm -lc
See -library=l[,l...] for more information.