Linking D Runtime
H. S. Teoh
hsteoh at quickfur.ath.cx
Sat Aug 24 01:19:01 UTC 2019
On Sat, Aug 24, 2019 at 12:26:43AM +0000, Jonathan Levi via Digitalmars-d-learn wrote:
> I am trying to find the D runtime/standard-library
> object(.o)/library(.a) files inorder to link them with some foreign
> code (Haskell as it happens).
>
> I am writing a program in Haskell but want to use D for some of the
> imperative style logic. I expect to have a large section of code in D
> so I want to take advantage of the D runtime, garbage collector, and
> standard libraries.
>
> I found several discussions on getting the D runtime going, so I
> expect that to be easy, but (obviously) I get link errors when I do
> not have it to link.
>
> What is the advised way to get the object(.o)/library(.a) files for
> the D runtime and standard library?
[...]
Not sure what's the "right" approach, but you could try compiling with
dmd -v to find the path(s) to the runtime libraries that you'll need to
link.
Keep in mind that before calling any non-trivial D code (i.e., that uses
the GC or any druntime function, including language hooks) you need to
call core.runtime.rt_init first. And preferably at shutdown call
core.runtime.rt_term to cleanup.
Not sure what will happen if more than one D library does this, though.
My guess is that you'll somehow need to get them all to link to (or
otherwise be aware of) a single instance of the D runtime, otherwise you
might get some weird runtime behaviour when the two runtimes conflict
with each other.
T
--
Indifference will certainly be the downfall of mankind, but who cares? -- Miquel van Smoorenburg
More information about the Digitalmars-d-learn
mailing list