Re: Consuming D libraries from other languages
On Wednesday, 15 June 2022 at 17:37:32 UTC, Templated Person wrote: It there any resources on how to build D static (`.lib` / `.a`) and dynamic libraries (`.dll` / `.so`), and then use them from C? Do I need to link and initialize phobos somehow? What if I don't want to use the D runtime? What happens with module level `this()` and `~this()`? Is there a comprehensive guide on how to do this stuff? Check: https://code.dlang.org/packages/autowrap And examples such as c#, Python here: https://github.com/symmetryinvestments/autowrap/tree/master/examples
Re: Consuming D libraries from other languages
On 6/15/22 10:37, Templated Person wrote: > It there any resources on how to build D static (`.lib` / `.a`) and > dynamic libraries (`.dll` / `.so`), and then use them from C? > > Do I need to link and initialize phobos somehow? Not Phobos but the D runtime. > What if I don't want to > use the D runtime? What happens with module level `this()` and > `~this()`? I had difficulty figuring out how everything fit together in a complicated scenario. (Different language runtimes calling each other and starting the D library.) However the following worked. > Is there a comprehensive guide on how to do this stuff? I gave a DConf presentation that answers some of your questions: https://dconf.org/2020/online/ Please click the 'November 22' tab on that page to expand "Exposing a D Library to Python Through a C API". But here are the links: Slides: https://dconf.org/2020/online/slides/ali-2.pdf Video: https://youtu.be/FNL-CPX4EuM Q: https://youtu.be/M5wtRgfAoAA Ali
Re: Consuming D libraries from other languages
On Wednesday, 15 June 2022 at 19:36:34 UTC, Guillaume Piolat wrote: BindBC bindings are multi-platform and can be both static and dynamic linking. My bad I understood the reverse, consuming C libraries from D. I think what you are seeking is described in the D blog.
Re: Consuming D libraries from other languages
On Wednesday, 15 June 2022 at 17:37:32 UTC, Templated Person wrote: It there any resources on how to build D static (`.lib` / `.a`) and dynamic libraries (`.dll` / `.so`), and then use them from C? Do I need to link and initialize phobos somehow? What if I don't want to use the D runtime? What happens with module level `this()` and `~this()`? Is there a comprehensive guide on how to do this stuff? What I would suggest is to look at a few of the BindBC libraries and mimic them. https://code.dlang.org/search?q=bindbc BindBC bindings are multi-platform and can be both static and dynamic linking. They can also work without a D runtime.
Consuming D libraries from other languages
It there any resources on how to build D static (`.lib` / `.a`) and dynamic libraries (`.dll` / `.so`), and then use them from C? Do I need to link and initialize phobos somehow? What if I don't want to use the D runtime? What happens with module level `this()` and `~this()`? Is there a comprehensive guide on how to do this stuff?