October 29, 2013 Re: Dynamic loading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Benjamin Thaut | On 10/27/2013 09:23 AM, Benjamin Thaut wrote: > Am 27.10.2013 09:08, schrieb Steve Teale: >> Any progress? > > Yes. The implementation of the linux part seems to be done and will be > included in 2.064. On windows it will take some time because "export" > has to be fixed first. > > Kind Regards > Benjamin Thaut Not entirely true. We have the basic low-level support but the high-level stuff isn't ready for this release (https://github.com/D-Programming-Language/druntime/pull/617). If you're curious you can try the low-level stuff. Currently the most accurate howto is the unittests :(, (https://github.com/D-Programming-Language/druntime/tree/master/test/shared). |
October 29, 2013 Re: Dynamic loading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Teale | On 10/28/2013 07:00 PM, Steve Teale wrote: > > That sounds a bit implausible. New language keyword or something to load > a library or object file. My best guess is that extern(C) dlopen() will > just work correctly, failing that I'd think we need an equivalent Phobos > call. We need another runtime layer to account for per-thread initialization/finalization of modules (static this()/static ~this()). There is Runtime.loadLibrary/Runtime.unloadLibrary and rt_loadLibrary/rt_unloadLibrary to do this. You can use dlopen from a C executable but the loaded D library is only usable from the loading thread. For a C executable the recommended pattern is to dlopen or link druntime (libphobos2.so) and to use rt_loadLibrary/rt_unloadLibrary to load D libraries. Currently the best available documentation are the tests (https://github.com/D-Programming-Language/druntime/tree/master/test/shared). |
Copyright © 1999-2021 by the D Language Foundation