Creating a C#/Typescript GUI for a C++ library

3 years ago by canpolat to c/ask_experienced_devs

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.

fbmac 2 points 3 years ago

A very long time ago I did it for C# writing a wrapping C++/CLI library. For other languages I would probably make a C wrapper library

path: 0 3472511, hotness: undefined, score: 2, children: 0
RandomDevOpsDude 2 points 3 years ago

Depending on where you want your app to run, QT framework/creator has pretty powerful C++ GUI capabilities. The biggest benefit, I thought, is a lot of open source projects use it (e.g. Bitcoin and forks) meaning there are a lot of real examples out there rather than only docs.

The other option, which is more aligned with separate frontend/backend and WebApps, is simply have a basic server of some type wrapping the dll functionality you want to use as endpoints and communicate over ReST API.

path: 0 534255, hotness: undefined, score: 2, children: 0
Hotzilla 2 points 3 years ago

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/...

path: 0 527696, hotness: undefined, score: 2, children: 4
canpolat 1 point 3 years ago

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.

path: 0 527696 530217, hotness: undefined, score: 1, children: 3
ishanpage 1 point 3 years ago

You can do this with Emscripten. See here and here

path: 0 527696 530217 687908, hotness: undefined, score: 1, children: 1
canpolat 1 point 3 years ago

Thank you. I saw those pages, but what I can do was not immediately clear. I was looking for some examples (probably there are some videos on YouTube). I will have some more time to dive into this soon. Maybe I'll hack around and see if it works for me.

path: 0 527696 530217 687908 688061, hotness: undefined, score: 1, children: 0
FlorianSimon 1 point 2 years ago
path: 0 527696 530217 9874570, hotness: undefined, score: 1, children: 0
ask_experienced_devs
ask_experienced_devs

@programming.dev

login for more options
1517
63
8

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

go to feed...