Haskell calling D code through the FFI

Jon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 5 16:01:26 PDT 2014


Oh great thank you.  I think that might solve the majority of the 
confusion I was having.  One thing I can't figure out though, is 
getting garbage collection to work as expected.  If I have a 
function that allocates a pointer to a struct using new, I get an 
error on linking _dAlloc... not found.  But maybe compiling as a 
lib will solve this too.

On Tuesday, 5 August 2014 at 21:28:08 UTC, David Soria Parra 
wrote:
> On Monday, 4 August 2014 at 20:48:09 UTC, Jon wrote:
>
>> For reasons I don't completely understand, you also need a 
>> fake main function, dummy.d:
>>
>>    void main(){}
>>
>
> Note that this is not necessary if you compile with -lib e.g.:
>
>   dmd -lib -oflibtest.a test.d
>
> and then
>
>   ghc Main.hs --make -omain libtest.a
>
> I don't have gdc or ldc installed but as far as I know ldc has 
> a -lib flag as well.



More information about the Digitalmars-d-learn mailing list