Chapter 57. Loading shared libraries

#include <x/ltdl.H>

auto shlib=x::ltdl::create("libmymodule");

auto function=shlib->sym<int (*)()>("function");

int ret=(*function)();

x::ltdl implements a reference-counted wrapper around libtool's libltdl library that implements dynamic loading and unloading of shared libraries. create() loads the specified shared library, after which use sym() to look up symbols in the shared library.


Mangled C++ names should be used, where applicable.

See the x::ltdl::base documentation for more information on several options related to loading shared libraries, and libtool's documentation, for more information.