xmllmx xmllmx - 1 year ago 102
Linux Question

Why does we need libstdc++.so?

  • Most components of the C++ standard library are exported in source
    code form, that is, provided in header files only.

  • Most functions of the C library are provided by libc.so.

So, my questions are:

Why does we need libstdc++.so?

What contents are in libstdc++.so?

Answer Source

There are plenty of symbols which are defined in the library. Notably, much of the language support and all of the standard library exception classes are defined in library.

Even if many of components in the standard C++ library are templates and, thus, have an inline definition, they do benefit from being explicitly instantiated. Using explicitly instantiations of the IOStreams library (and declaring them as extern templates) greatly improves compile-times.

To figure out what symbols are defined in the library use nm: it will print the symbols defined and referenced by a library. The names may be mangled which will be fixed by piping the result to a suitable c++filt.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download