Skip to content

A template for loading objects of type T from a dynamically loaded library (at runtime).

Notifications You must be signed in to change notification settings

christopherpoole/cppplugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

C++ Shared Object Plugin

A template for loading objects of type T from a dynamically loaded library. The shared object, or plugin, must have entry and exit functions designated extern "C" which manage the construction and destruction of T.

For an advanced usage example have a look at G4Plugin. And for a more descriptive statment on what this is all about, have a look at the wiki page: https://github.com/christopherpoole/cppplugin/wiki/Plugins-in-CPP:-Dynamically-Linking-Shared-Objects

Author: Christopher M Poole

Email: mail@christopherpoole.net

Basic Example Usage

Target Object:

class Thing;

User Plugin:

extern "C" Thing* load() {
    Thing * thing = new Thing();
    return thing;
}

extern "C" void unload(Thing * thing) {
    delete thing;
}

Application:

Plugin<Thing> * plugin = new Plugin<Thing>("./shared.so",
                                           "load", "unload");
Thing * thing = plugin->Load();

/** use thing **/

plugin->UnLoad();

About

A template for loading objects of type T from a dynamically loaded library (at runtime).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages