Linking C libraries with DMD

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 2 12:06:05 PST 2016


On Friday, 22 January 2016 at 04:43:52 UTC, Mike Parker wrote:
> [snip]

Thanks again for your help. I've worked through some simple 
examples and started trying to write a binding to a C library.

I think I've got the .h file converted properly (the D file 
compiles), but I was getting a linking error. The enums were 
showing up, but not the functions. I tried creating a simple 
project that mimics what was happening in the C library and found 
no issues.

I think I narrowed it down to what is causing the linking error. 
I had not compiled the C dll myself. Looking in to the issue, I 
noticed it was compiled with MinGW. There were instructions for 
using it with Visual Studio (to make the .def and .dll files into 
a .lib) though and I assumed following those was sufficient. 
However, based on what you've said, I suspect that if I 
re-compile the dll using Visual Studio, then it will work with D.

I don't think I would have figured that out without your comments 
above.


More information about the Digitalmars-d-learn mailing list