Basic DerelictOrg and Deimos question
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Oct 24 21:38:12 PDT 2014
On Friday, 24 October 2014 at 18:16:52 UTC, Justin Whear wrote:
> On Fri, 24 Oct 2014 18:04:13 +0000, WhatMeWorry wrote:
>
>> Just for clarity's sake, should I consider the DerelictOrg and
>> Deimos
>> (packages, projects, or libraries) as separate from one
>> another? Or
>> does DerelictOrg use Deimos behind the scenes?
>
> They are quite different. The Deimos packages are static
> bindings to the
> C
> libraries--requiring you to statically link. This,
> incidentally is why
> there
> is no Deimos binding for OpenGL: it cannot be statically linked
> (unless
> you go
> with a software implementation like MESA) because libGL is
> provided by the
> end user's video hardware drivers.
To clarify a bit for the OP, I should point out that this isn't
actually correct. To get the terminology straight, there are two
types of linking. Static linking means linking with a static
library. Dynamic linking means linking with an import library on
Windows or directly with a .so on Posix systems. Static bindings
support both types, so Deimos does not preclude you from using
shared libraries. It just always has a link-time dependency.
Dynamic bindings have no link-time dependencies at all. They
cannot be linked with either static or shared libraries (because
the external functions are actually function pointers). Instead,
they use a process called 'dynamic loading' to pull the shared
library into the process space at run time.
When I first came to D over 10 years ago, the only OpenGL binding
out there was a static one. It's quite possible to link with the
OpenGL shared library to get whatever the system provides and
then pull in later versions at run time. For example, on Windows
you could get 1.1 by linking (IIRC up to 1.4 since Vista or maybe
Win 7), but had to load the rest at run time. Of course, OGL is a
special case.
More information about the Digitalmars-d-learn
mailing list