Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Shared Libraries

Name Resolution
Other Issues with Shared Libraries
Possible Inefficiencies in Shared Libraries
shared_library class

A shared_library refers to a loadable module, the type of which depends on the platform:

Normally, shared libraries are loaded by an application when it starts. This is commonly used by Boost libraries that can be built as shared libraries, such as Boost.Thread or Boost.Filesystem.

Shared libraries can also be loaded at will, during program execution.

Whenever a shared library is loaded, either at load time or later during a program's execution, the function and variable locations in the library are resolved.

A loaded shared library can be searched for functions or data. In C++, this requires that the function be marked as follows:

\code extern "C" void MyFunction() { // do stuff } \endcode

The reason for this is the name-mangling that C++ performs, to give different names to, for instance, multiple overloads with the same function name.

Because different compilers mangle names differently (and in ways that are often undocumented), it would be very difficult to create a cross-platform solution to avoid the use of extern "C" declarations. This is the primary cause of the inherent lack of type-safety with calls in the shared_library class.


PrevUpHomeNext