runtime evaluation

Mike Parker aldacron at gmail.com
Sat Dec 14 06:30:23 PST 2013


On 12/14/2013 11:07 PM, hoya wrote:
> On Saturday, 14 December 2013 at 13:45:00 UTC, Jacob Carlborg wrote:
>> You can instantiate classes at runtime using Object.factory. You can
>> also loaded classes using dynamic libraries, just as in C or C++.
> Yes, but loading a dynamic lib (shared) in C/C++ is at compile type, if
> I remembering right. But is there a way in D like dlopen() in C, which
> can be used at runtime?
>
That's what Jacob is talking about. D can interface with C libraries 
just fine, so dlopen() is available on Posix systems and LoadLibrary on 
Windows. That's the approach I use with the C library bindings in 
Derelict[1].

Shared libraries are never loaded at compile time. You can link with an 
import library (on Windows) or directly with the shared object, but that 
just sets the executable up so that the library is loaded by the OS when 
the app starts up. dlopen and friends eliminate the need for a link 
step, but require more effort to load manually.

[1] https://github.com/DerelictOrg


More information about the Digitalmars-d mailing list