C
C#2mo ago
Glacie

How does managed C++ work for interoping with C# code?

here's the deal. I'm learning C# by writing a media player that supports wav and ogg loop points(cause most media players seem to ignore loop points in wav and ogg headers and opt to loop the entire track instead, which is awful for game music). the SDl2(SDL2_Mixer, actually) bindings for C# aren't very fun to work with, mostly due to the fact that C# is fairly high level. so, I've decided to mostly write the actual audio driver code in C++, while using C# for the audio player state, UI, settings, etc. (I understand I could use NAudio or some other audio mixer, but I'm familiar with SDL2_Mixer and don't want to learn an entirely new API unless I have to) now.. how exactly does managed C++ work? from what I understand from researching, managed C++ allows you to use C++ classes(?) as .NET modules? that seems to be what I'm looking for. but how do I get that set up with the dotnet runtime on linux? (that is to say, I'm using dotnet to run .NET modules.) every guide and resource I found is for windows with Visual Studio(which I can't run on linux, and even if I could with WINE, my laptop is way too low end to really use it efficiently). I also understand that I can compile unmanaged C++ as a .dll library? if that's less painful to set up on linux, then that's the route I'll go. but I'd like the get managed C++ working if possible. Thanks!
3 Replies
Jimmacle
Jimmacle2mo ago
C++/CLI is windows (and MSVC) only you need to look at P/Invoke if you want something that will work on linux
Glacie
Glacie2mo ago
ah okay. thanks