www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Best way to use C library

reply Maximilian Naderer <maximilian.wallinger outlook.com> writes:
Hello guys,

So what’s currently the best way to use a big C library?

Let’s assume something like

cglm
assimp
glfw

ImportC doesn’t really work for such huge libraries, I’ll 
investigate further. Deimos is outdated or there are no bindings. 
I know that there is a dub package for glfw which works fine. But 
how would I do something for assimp or cglm. The dub assimp 
package is quite outdated.

Am I stuck with manually creating interface files either by hand 
or automation?

I’m hope somebody could give me some insights. Thank you !

Kind regards from Austria
Max
May 19 2023
next sibling parent jmh530 <john.michael.hall gmail.com> writes:
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

 ImportC doesn’t really work for such huge libraries, I’ll 
 investigate further. Deimos is outdated or there are no 
 bindings. I know that there is a dub package for glfw which 
 works fine. But how would I do something for assimp or cglm. 
 The dub assimp package is quite outdated.

 Am I stuck with manually creating interface files either by 
 hand or automation?

 I’m hope somebody could give me some insights. Thank you !

 Kind regards from Austria
 Max
If there are issues using those libraries, you should report the bugs.
May 19 2023
prev sibling next sibling parent user456 <user456 123.de> writes:
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

 ImportC doesn’t really work for such huge libraries, I’ll 
 investigate further. Deimos is outdated or there are no 
 bindings. I know that there is a dub package for glfw which 
 works fine. But how would I do something for assimp or cglm. 
 The dub assimp package is quite outdated.

 Am I stuck with manually creating interface files either by 
 hand or automation?

 I’m hope somebody could give me some insights. Thank you !

 Kind regards from Austria
 Max
If you aim static linking or static binding then you can give [dstep](https://github.com/jacob-carlborg/dstep) a shot. Otherwise and if you have the time to then dont forget to report the problems founds when you have tried ImportC.
May 19 2023
prev sibling next sibling parent Guillaume Piolat <first.last spam.org> writes:
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.
May 22 2023
prev sibling parent reply Theo <Theo gmail.com> writes:
On Friday, 19 May 2023 at 18:31:45 UTC, Maximilian Naderer wrote:
 ..
 I’m hope somebody could give me some insights. Thank you !

 Kind regards from Austria
 Max
DConf Online '22 - Translating C to D (Dennis Korpel) https://www.youtube.com/watch?v=654rSPaIA0o
May 22 2023
parent Maximilian Naderer <maximilian.wallinger outlook.com> writes:
On Monday, 22 May 2023 at 22:22:50 UTC, Theo wrote:
 On Friday, 19 May 2023 at 18:31:45 UTC, Maximilian Naderer 
 wrote:
 ..
 I’m hope somebody could give me some insights. Thank you !

 Kind regards from Austria
 Max
DConf Online '22 - Translating C to D (Dennis Korpel) https://www.youtube.com/watch?v=654rSPaIA0o
Thank you very much for the insights so far. I'll check them all out! BR, Max
May 24 2023