Using D libs in C

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Jan 19 06:40:33 PST 2011


On 1/19/11, GreatEmerald <pastas4 at gmail.com> wrote:
> All right, it worked, when the D side is this:
>
> module techborg;
> import std.c.stdio;
>
> extern(C):
>     shared int ResultD;
>
>     int Process(int Value)
>     {
>         printf("You have sent the value: %d\n", Value);
>         ResultD = (Value % 5);
>         return ResultD;
>     }
>
> However, if I wanted to use printf() from std.stdio, dmc can't link
> the library any more and complains about undefined symbols:
> techborg.lib
>  Warning 140: Library probably needs FIXLIB
> techborg.lib(techborg)
>  Error 42: Symbol Undefined _D3std5stdio12__ModuleInfoZ
>
> Also, what was that solution you found for converting OMF->COFF? I
> can't seem to find the post you mentioned.
>

That's odd. stdio publicly imports std.c.stdio which publicly imports
core.stdc.stdio, where printf is located. Maybe it's a linker bug..

My post was here, I'm not sure why it's not displayed:
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=127079


More information about the Digitalmars-d-learn mailing list