Linking D Runtime

Jonathan Levi catanscout at gmail.com
Tue Sep 3 01:45:44 UTC 2019


On Saturday, 24 August 2019 at 00:26:43 UTC, Jonathan Levi 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?
>
> Thanks!

Okay,

It looks like what needs to be found are "libphobos2" and 
"libdruntime".  They can be found where ever your system puts lib 
files.  Windows (as far as I know) does not have a joined place 
for lib files so you need to look where dmd/ldc/etc installed 
itself.  On Linux lib files are generally put in `/usr/lib`.  
Ideally the hunting for lib files should be left to a build tool 
in order to be system agnostic.  In Cabal (Haskell's build tool) 
add "druntime" and "phobos2" to `extra-libraries`.


More information about the Digitalmars-d-learn mailing list