dll is a simple library used to manage the loading and calls of dynamic loaded libraries.
Let’s suppose you have defined a module library called
my-module into a package called
my-package. To load
my-module from a library or an application:
- In CMakListst.txt:
- You have just to include
pid/dll.hto get access to
- Loading of the DLL is made at
DLLLoaderobject construction time, and unloading is automatically performed when object is destroyed.
- Use the
symbolmethod to get the corresponding symbol or get an exception if the symbol does not exist. Use
has_symbolto check whether a symbol exists.
Remark: Dependency to
my-module in CMakeListst.txt is optional but is the preferred way because it lets PID version resolution automatically solve the version of
my-module but also solve version for all its direct or undirect dependencies. The good point is that version resolution is globally secure, the bad point is that it forces to solve the global configuration of an application at its configuration phase which may be contradictory with highly runtime configurable plugin system.
The alternative is so to avoid declaring a dependency with the module:
Then in C++ code you can for instance do :
The main difference here is that you must use a version constraint that follows the pattern defined by
pid-rpath api. Previous code respectively tell to load the exact version 1.4.3 of
my-package and to load any version greater or equal than 1.4.3.