I would love to get more in D, but the lack of good library support really bothers me. Therefore, I would like to create some D bindings for existing C libraries that I would like to use. I have never done bindings, but it is also not too difficult.
I plan to do this for D2 (not specifically D1, but if it can be for both, even better). I am using the DMD2 compiler.
- What conventions should be used (I noticed version statements, aliases and regular constants / function definitions)?
- What is the difference between binding to a static library (and therefore related) or a dynamic library? Is there a difference in binding?
- To bind a static library, the DMD compiler does not seem to accept .a or .o files, only .lib and .obj. Does this mean that libraries must be compiled using the DMC compiler (as opposed to the GCC compiler) and then linked through the DMD compiler?
If someone had a very short example of how the binding would be done, I would be very complete. Currently, I can compile C code with DMC, link object files and run functions from C code in D. However, most C libraries just need to include the header file and need to link it to C. I'm not sure how to make the bindings that work for this ...
Thanks!
c binding d dmd
Taco de wolff
source share