Calling c++ library from .NET MAUI blazor or MAUI xaml

Nilesh Kalyankar 20 Reputation points
2024-06-14T08:21:15.94+00:00

Hi,

We are building cross platform application and searching whether we can call C++ library from .NET MAUI Blazor or .NET MAUI xaml.

Could anyone advise the feasibility and if feasible any end to end example to refer.

We are looking for cross platform functionality on iOS, Android and Windows.

Developer technologies .NET .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-06-14T16:08:32.5333333+00:00

    Maui apps can call c/c++ via the p/invoke library:

    https://learn.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke

    the main task is to define the entry points and mapping (marshalling) of the parameters. you usually use .h file to determine how to do this. Calling native libraries is common enough with Maui, there is support for binding libraries (generated wrappers):

    https://learn.microsoft.com/en-us/shows/dotnetconf-focus-on-maui/binding-native-libraries-for-dotnet-maui

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.