Undefined Reference calling D from C using static linking

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 23 03:16:22 PDT 2017


On Thursday, 23 March 2017 at 09:11:28 UTC, data pulverizer wrote:
> I am trying to call a D function from C. Here is the D code:
>
> ```
> /* dcode.d */
> extern (C) nothrow @nogc @system {
>     double multNum(double x, double y)
>     {
>         return x*y;
>     }
> }
> ```
>
> [...]

It has to do with module references to druntime stuff. You can 
either try adding a

pragma(LDC_no_module_info); //I think it is spelled correctly.

or you can use ldc to link and it will link druntime

gcc ccode.c -c
ldc2 dcode.d code.o

I don't know how well that will work.


More information about the Digitalmars-d-learn mailing list