You can arrange to have d's runtime initialized when dlopen loads
the shared lib by adding a small shim that uses gcc attributes,
as follows:

// shim.c

__attribute__((constructor))
static void dinit() {
     rt_init();
}
__attribute__((destructor))
static void dfini() {
     rt_term();
}

// end of shim.c

Compile this to a .o with gcc, then include the .o in the build.
Note that I've only tried this trick with a simple "hello world"
shared lib, so I apologize in advance if it doesn't work for
real-world uses.

Reply via email to