Linking to C library [gdc/mac]
Johan Granberg
lijat.meREM at OVE.gmail.com
Sat Jan 6 10:18:20 PST 2007
Graham MacDonald wrote:
> Apologies if this has been asked previously - I'm new to D and haven't
> seen the info anywhere.
>
> I want to use a C library (glfw, probably others) from within my D code.
> I want to link using gdc. How can I do this? Am I right in thinking
> I would have to create a D module (as described for dmd in
> http://www.digitalmars.com/d/htomodule.html)?
>
> Thanks!
>
> Graham
Firstly glfw has d bindings already created in the standard distribution.
Secondly you can call any c function by declaring it for
example "extern(C)int write(char*);".
If you intend to use only a small subset of a library this is simpler than
creating an entier d module. (a d module for linking with c is just some
extern(c) declarations of structs and functions and some glue code to
handle defines)
More information about the D.gnu
mailing list