How do I interface D to a C library based on a DLL?

Christopher Grantham cgrantham at gmail.com
Tue Jun 12 21:00:47 PDT 2007


Hi,
     I'm very new to D, I have worked with other typical languages 
previously (C, C++, Java etc) and have some familiarity with .NET 
(mainly Visual C++), I need to use a C API in the form of a DLL for my 
uni work (research) and would like to try some experiments in D (I hate 
VC++ - IJW & M$ interop be damned!), I have the interface (.h), .LIB and 
.OBJ files as well as the DLL itself, but I'm not sure how to go about 
using/Linking the API in D, I've used it in VS.NET (VC++) but want to 
get away from it and use D if possible.
The DLL is closed source/proprietary so I can only edit the interface; 
I've read the 'Converting C .h files to D Modules' 
(http://www.digitalmars.com/d/htomodule.html), 'Writing Win32 DLLs in 
D'(http://www.digitalmars.com/d/dll.html), 'Converting C .h Files to D 
Modules' (http://www.digitalmars.com/d/htomodule.html), and 'Interfacing 
to C' (http://www.digitalmars.com/d/interfaceToC.html), however it isn't 
clear from these articles (at least to a n00b like myself) how I can use 
this C interfaced DLL in D code.
So far I've tried converting the header to D (manually), which hasn't 
worked (I get error: 138 data corruption), I think I should be able to 
interface directly to the C code, but am not confident.
If someone could assist/explain how to get D code working with a C 
interface from a DLL, then I'd be most grateful.

Thanks in advance.
Chris.


More information about the Digitalmars-d-learn mailing list