steavy
steavy

Reputation: 1576

Xamarin and c++ code

Currently I`m exploring how to write mobile apps for Android using Xamarin and C#. Also I have some c++ libraries(and source code for them) that should be used in application. These libraries are responsible for communication via internet(just to say).

So it is possible to use this c++ code in xamarin.android project? Or it should be rewritten in c# to be used?

Upvotes: 7

Views: 7185

Answers (2)

Michiluki
Michiluki

Reputation: 505

Im not sure with networking but most C++ code can be used 100% in Xamarin.

If it works, you can't be sure if it works correctly in every situation on IOS. We had the same problem with using UDP Sockets for VOIP(C#). Most of the time it will work, but in case of VOIP you need to use iOS sockets so you can set them to a special mode so they won't be closed when the app gets paused.

So it depends on what you want to do and how the C++ code is written. Im not sure if you can use normal unix sockets when using C++ on iOS but that should be the only problem when using it.

Just checked: Does Mac/IOS use the same sys/socket.h as the Linux kernel?

I think, if your library uses BSD sockets everything should be fine.

Upvotes: 4

Simple Fellow
Simple Fellow

Reputation: 4622

Usually it is possible to call some code in any other library unless

  1. It exports the functionality
  2. There is a wrapper in your language to make use of that exported functionality.

I do not know much about this Xamarin thing but I guess you should see if the library is binary compatible not code (i.e) that compiles with the source of your C++ project and you can make calls to it from your C# program.

Also while checking the Zamarin library documents, it seems that not every piece of C# code can be used on Xamarin platform. Please check the Xamarin community and the forums for more in details.

Upvotes: 1

Related Questions