简体   繁体   中英

Create shared library from c-source code for Xamarin Android

I'm trying to build a simple sip-application using Xamarin Forms. I use PjSip as a tool to sip functionality. I have a source-file (.c) with some methods which I want to call from my Xamarin application.
I have already built a static library (.a) for Xamarin ios and created a wrapper using p/invoke to call methods from my c-file. And it works perfect. But now I'm stuck on building shared libs (.so) to use them in Xamarin android.
I'm looking for step-by-step guide building shared libraries for Xamarin android starting with c-source code and ending with linking libs to a real Xamarin Android application. But still I would very appreciate any help.

This is what you are looking for:

Build and Debug C++ Libraries in Xamarin.Android Apps with Visual Studio 2015

Overview

  • Install Visual Studio 2015
  • Create a new Visual C++ Dynamic Shared Library project
  • Reference this project in you Xamarin project
  • Use DllImport to access the C code. Example:

     [DllImport ("sanangeles", EntryPoint = "Java_com_example_SanAngeles_DemoGLSurfaceView_nativePause")] static extern void nativePause (IntPtr jnienv); 
  • Browse this project to get a deeper view

When you do it like this you can even debug the C Code while running the Xamarin.Android app in Visual Studio 2015.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM