std.plugin ?

FreeSlave freeslave93 at gmail.com
Tue Oct 1 04:36:42 PDT 2013


On Tuesday, 1 October 2013 at 07:54:18 UTC, Jacob Carlborg wrote:
>
> Class loading, how necessary is this? We already have 
> ClassInfo.find and "create".

I just checked it on Linux. ClassInfo.find can't find the class 
from shared library. That's what I did:

//dmd rttitest.d baseclass.d -L-ldl
module rttitest;

import std.string;
import std.conv;
import std.stdio;
import std.c.linux.linux;

import baseclass;

int main()
{
     void* lib = dlopen(toStringz("./libdclass.so"), RTLD_LAZY);
     assert(lib, to!string(dlerror()));
     auto classInfo = ClassInfo.find("classimpl.MyClass");
     assert(classInfo, "Can't find ClassInfo");
     return 0;
}

module baseclass;

abstract class AbstractClass
{
     int doThing(int a, int b);
}

//dmd -shared -fPIC classimpl.d -I. -oflibdclass.so
module classimpl;
import baseclass;

class MyClass : AbstractClass
{
     override int doThing(int a, int b)
     {
         return a+b;
     }
}

I also tried to pass other flags to dlopen (RTLD_GLOBAL and 
RTLD_NOW) but it still does not work.


More information about the Digitalmars-d mailing list