I understand C# is available for Linux specifically Centos8:
https://docs.microsoft.com/en-us/dotnet/core/install/linux-centos
But can an application developed in C# for Linux/Centos8 call into libraries compiled for other languages, e.g., C++ or C?
I understand C# is available for Linux specifically Centos8:
https://docs.microsoft.com/en-us/dotnet/core/install/linux-centos
But can an application developed in C# for Linux/Centos8 call into libraries compiled for other languages, e.g., C++ or C?
It depends on the definition of call. Originally computer programs were only capable of static linking where multiple source files were compiled (by a compiler) then combined into a single executable file by a linker. That was how programming was originally done in Unix. About 40 years ago (before Windows) compilers (then operating systems) began to support dynamic linking. When Windows was developed it relied heavily on dynamic linking, right from the initial design. I believe that Windows supported dynamic linking before Unix did.
The .Net Framework does not support static linking. It is not possible to combine multiple computer languages in a single managed (.Net) executable file. It is possible to create a dynamic link library using a computer language such as C or C++ and call functions/methods in that library from a managed executable. I hope the following help.
I'll have to try it, but I believe your first and third options above, "Cross Platform P/Invoke" and/or "Interop with Native Libraries | Mono", will do what I need to do.
I was not intent on static linking, just anything that would permit a Linux C# main program to make use of [call] a C++ derived library without having to involve multiple processes.
Many thanks.
Many languages have managed versions, especially C++ but not C. I described Platform Invoke since you asked about languages in general. It is possible to write a managed C++ class library that can be called by C# in the same way as if the C++ class library is a C# class library, but I am not totally sure about the details of that for Linux. Managed C++ code can call unmanaged C++ and C, even using static linking.
10 people are following this question.