Linux Dynamic Loading of shared libraries

Steve Teale steve.teale at britseyeview.com
Sun Mar 9 05:07:20 PDT 2014


Martin Nowak's Gihub druntime Page has

module main;
import core.runtime, core.thread;

void main() {
     auto lib = Runtime.loadLibrary("./liba.so");
     auto thr = new Thread({
         auto lib = Runtime.loadLibrary("./liba.so");
         Runtime.unloadLibrary(lib);
     });
     thr.start();
     thr.join();
     Runtime.unloadLibrary(lib);
}

module liba;
import std.stdio;

shared static this() { writeln("shared static this()"); }
shared static ~this() { writeln("shared static ~this()"); }
static this() { writeln("static this()"); }
static ~this() { writeln("static ~this()"); }

Now suppose that my D shared library contains a class, rather 
that just module ctors/dtors, how do I go about creating an 
instance of that class and using its methods?

Steve


More information about the Digitalmars-d-learn mailing list