Xamarin code and C ++

I am currently learning how to write mobile apps for Android using Xamarin and C #. I also have some C ++ libraries (and source code for them) that should be used in the application. These libraries are responsible for communication over the Internet (just say).

So can this C ++ code be used in a xamarin.android project? Or should it be rewritten in C # to be used?

+4
source share
2 answers

I'm not sure about the network, but most C ++ code can be used 100% in Xamarin.

If this works, you cannot be sure that it works correctly in every situation on iOS. We had the same problem using UDP sockets for VOIP (C #). It will work most of the time, but in the case of VOIP, you need to use iOS sockets so that you can set them to special mode so that they do not close when the application is paused.

So, it depends on what you want to do and how the C ++ code is written. I'm not sure if you can use regular unix sockets when using C ++ on iOS, but this 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.

+3
source

You can usually call some code in any other library if

  • It exports functionality
  • There is a shell in your language to use this exported functionality.

I don't know much about this Xamarin thing, but I think you should see if the library is compatible with binary code, not code (i.e.) that compiles with the source of your C ++ project and you can call it from of your program in C #.

In addition, checking the documents of the Zamarin library, it seems that every fragment of C # code cannot be used on the Xamarin platform. Please check out the Xamarin community and forums in more detail.

+1
source

Source: https://habr.com/ru/post/1502601/


All Articles