Linking C libraries with DMD
Dibyendu Majumdar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 21 13:39:08 PST 2016
On Thursday, 21 January 2016 at 16:14:40 UTC, jmh530 wrote:
> I'm trying to understand calling C libraries from D on Windows
> with DMD. I made a simple example and compiled it with a static
> library fine (so I've converted the .h file correctly). Then, I
> compiled with gcc to a shared library (because I cannot for the
> life of me figure out how to do this with DMC). I then used
> implib to generate a .lib file (the fact that this is necessary
> is not described nearly well enough in the documentation).
Hi I am also new to D and trying to do similar things - i.e. call
a shared library written in C from D, but also create a shared
library in D.
For the latter - on Windows 10 b64-bit - I am using following
options for example:
-shared -L/LIBPATH:c:\\lib -L//IMPLIB:mylib.lib
In my case I would like stuff from my D code to be exported. I
found that I need to do following if I want to export a C API.
extern (C) export void myfunc();
I did not find examples of how to export D classes / functions -
and right now I am getting link errors when trying to export D
code.
Regards
Dibyendu
More information about the Digitalmars-d-learn
mailing list