Best way to use C library

Guillaume Piolat first.last at spam.org
Mon May 22 20:10:56 UTC 2023


On Friday, 19 May 2023 at 18:31:45 UTC, Maximilian Naderer wrote:
> Hello guys,
>
> So what’s currently the best way to use a big C library?
>
> Let’s assume something like
>
> cglm
> assimp
> glfw

- Some big libraries are translated, for example 
https://code.dlang.org/packages/glfw-d was created with both 
manual work and ctod 
(https://forum.dlang.org/thread/hfpirezenlabjqtwejyk@forum.dlang.org) Even then it is pretty manual and AI barely help with D.

- Some libraries can be loaded with BindBC (typically 
dynamically) so that you can use existing builds. 
https://code.dlang.org/search?q=bindbc
       Creating a new BindBC-style package is typically manual but 
normally low maintenance after the fact.


Now, if using a complex C++ libraries involves inlined C++ types, 
it will be a lot harder to create a nice D port.
A library like cglm almost must be ported, a bindings won't help 
here, since it's probably lots of inlined C++ types in headers. 
You can use the package inmath instead.



More information about the Digitalmars-d-learn mailing list