this post was submitted on 25 Jun 2023
1 points (100.0% liked)

Ask Experienced Devs

1064 readers
1 users here now

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

I'm a back-end developer who wants to play with some desktop/front-end development.

I found a C++ library and started thinking what would be the best way to wrap this library in a way so that I can create a GUI in either C# or in Typescript.

What would you recommend?

Note: I'm trying to keep the question relatively vague because I want to get some ideas to try instead of finding the solution to my specific problem. I want to learn more about how others would approach such a problem. But I can provide more details, if necessary.

top 3 comments
sorted by: hot top controversial new old
[–] Hotzilla@sopuli.xyz 0 points 1 year ago (1 children)

Not an easy task, but if your C++ library is DLL you can use interop to load and use it on C#. If the library is larger than just one DLL, then it goes even harder. https://learn.microsoft.com/en-us/dotnet/framework/interop/consuming-unmanaged-dll-functions

[–] canpolat@programming.dev 0 points 1 year ago (1 children)

Thank you for the response. To be honest, I'm a bit surprised that this is not an easy task. If I understand the documentation correctly, that means, I will have to create a C# wrapper for C++ methods. I was hoping to get the wrapping for free via some tooling. I found Emscripten that looks promising (for JS), but not sure that's any different.

[–] FlorianSimon@sh.itjust.works 1 points 5 months ago

There's also Swig, but it sucks from what I've been told.