Forum General

How to build cross platform dynamic library?

ChangGYChangGY Member ✭✭

I'm using Delphi to build cross platform dynamic library (.dll on Windows, .dylib on Mac, and .so on Android), and we want to switch to C#.
Can xamarin do this?

Posts

  • ChangGYChangGY Member ✭✭

    I want to export functions that can be use with any language.

  • ChangGYChangGY Member ✭✭

    Still cannot solve this problem

  • JohnHardmanJohnHardman GBUniversity mod

    @ChangGY said:
    I'm using Delphi to build cross platform dynamic library (.dll on Windows, .dylib on Mac, and .so on Android), and we want to switch to C#.
    Can xamarin do this?

    In the Xamarin.Forms world, you would package your library code as a NuGet package. There is a lot of documentation online, but start with https://docs.microsoft.com/en-us/nuget/create-packages/overview-and-workflow

  • ChangGYChangGY Member ✭✭

    @JohnHardman said:

    @ChangGY said:
    I'm using Delphi to build cross platform dynamic library (.dll on Windows, .dylib on Mac, and .so on Android), and we want to switch to C#.
    Can xamarin do this?

    In the Xamarin.Forms world, you would package your library code as a NuGet package. There is a lot of documentation online, but start with https://docs.microsoft.com/en-us/nuget/create-packages/overview-and-workflow

    I want build a DLL/Dylib and load it in Excel on Windows and Mac, how to achieve it in xamarin?

  • JohnHardmanJohnHardman GBUniversity mod

    @ChangGY said:
    I want build a DLL/Dylib and load it in Excel on Windows and Mac, how to achieve it in xamarin?

    Building a DLL in C# is easy enough - see https://blogs.msdn.microsoft.com/benjaminperkins/2017/04/13/how-to-make-a-simple-dll-as-an-assembly-reference-just-for-fun/

    Whether a Dylib can be built in C# is not something I know. I suggest you ask that question in the Xamarin.Mac forum at https://forums.xamarin.com/categories/xamarin-mac or on StackOverflow

    If it is possible to create a Dylib in C#, then the general answer to your question is as follows (if it isn't possible to create a Dylib in C#, then you wouldn't want to be using Xamarin for this, so the following would not apply):

    I would package as much of the functionality as possible as a NuGet. You'd then have two projects that consume that NuGet. One would be a Class Library project for the DLL requirement, and the other (assuming it's possible) would be for the Dylib requirement. Whether you put those in one solution is a matter of personal preference, taking into account which machine (PC/Mac) you will be building each from.

    Of course, there is the question of whether the functionality involves a UI. If it does, my understanding is that you would have to code this for each platform, with the code in platform-specific projects in the NuGet. There are old forum posts where Xamarin staffers said that wrapping Xamarin.Forms in a class library is not possible, so any UI work would be platform-specific rather than using Xamarin.Forms. Those were old posts though, so it could be that this is no longer the case, although I've never seen anything to say that. You might want to check with the Xamarin support team direct. For how to do that, see https://forums.xamarin.com/discussion/150917/the-microsoft-xamarin-support-team-is-here-to-help#latest

    So, in summary, I don't know if what you want to do is possible, but the above should hopefully allow you to ask the right questions of the right people.

  • ChangGYChangGY Member ✭✭

    @JohnHardman said:

    @ChangGY said:
    I want build a DLL/Dylib and load it in Excel on Windows and Mac, how to achieve it in xamarin?

    Building a DLL in C# is easy enough - see https://blogs.msdn.microsoft.com/benjaminperkins/2017/04/13/how-to-make-a-simple-dll-as-an-assembly-reference-just-for-fun/

    Whether a Dylib can be built in C# is not something I know. I suggest you ask that question in the Xamarin.Mac forum at https://forums.xamarin.com/categories/xamarin-mac or on StackOverflow

    If it is possible to create a Dylib in C#, then the general answer to your question is as follows (if it isn't possible to create a Dylib in C#, then you wouldn't want to be using Xamarin for this, so the following would not apply):

    I would package as much of the functionality as possible as a NuGet. You'd then have two projects that consume that NuGet. One would be a Class Library project for the DLL requirement, and the other (assuming it's possible) would be for the Dylib requirement. Whether you put those in one solution is a matter of personal preference, taking into account which machine (PC/Mac) you will be building each from.

    Of course, there is the question of whether the functionality involves a UI. If it does, my understanding is that you would have to code this for each platform, with the code in platform-specific projects in the NuGet. There are old forum posts where Xamarin staffers said that wrapping Xamarin.Forms in a class library is not possible, so any UI work would be platform-specific rather than using Xamarin.Forms. Those were old posts though, so it could be that this is no longer the case, although I've never seen anything to say that. You might want to check with the Xamarin support team direct. For how to do that, see https://forums.xamarin.com/discussion/150917/the-microsoft-xamarin-support-team-is-here-to-help#latest

    So, in summary, I don't know if what you want to do is possible, but the above should hopefully allow you to ask the right questions of the right people.

    Thanks for the reply!

Sign In or Register to comment.