Shared objects?
Jacob Carlborg
doob at me.com
Mon Jun 18 08:06:07 PDT 2012
On 2012-06-18 16:56, Wouter Verhelst wrote:
> Hi group,
>
> I've been reading up on D for the past few days--something I'd been
> planning to do for quite a while--and find much to like and little to
> dislike; as such, I am considering using it for my next project, which
> would run on Linux (and possibly some other POSIX systems) and would
> need to load plugins.
>
> Now I've done such things in C in the past, and it's not too difficult:
> you create a .so file, have it call some initial function right after
> the dlopen(), and then have that initial function register the new
> functionality available.
>
> After looking at the documentation for a few days, I've come to the
> conclusion that with Object.factory and interfaces, I believe I can
> abstract things enough so that all a plugin would need to do is register
> a new class, which could then be instantiated if needs be.
Yes, in theory.
> However, what
> I don't find is the answer to the two following questions:
>
> - Does D support dlopen(), or some similar mechanism, to allow me to
> load plugins at runtime?
Yes. You can compile D code to a standard dynamic library, just as you
would using C.
> - If it does, does Object.factory() still work for new classes loaded in
> through dlopen() (or its functional equivalence)?
No.
Dynamic libraries are currently not working properly in D. The runtime
needs to be updated to handle it. There are some problem with module
info, exception handling tables and TLS. There might be some problem
left with PIC as well.
This is worked on and hopefully we will have a solution not too far in
the future.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list