Reputation: 1075
Mono noobie here,
I want to use an existing c++ library in an application I'm writing for iPhone and Android. I'm trying to find the best strategy to bind it to my Mono project, so that the changes from platform to platform will be minimal.
I tried to read about it on the web and came across CXXI, P/Invoke etc. but could not understand whether these methods work for all platforms. Also, I could not figure out whether CXXI is stable enough or if it fits MonoDroid and MonoTouch.
What method in your opinion is the most convenient and most cross-platform?
Upvotes: 4
Views: 362
Reputation: 43553
At the moment the easiest approach is to write C wrappers on your C++ library then write p/invokes for your (new) C API. This approach was used for the development of Moonlight (open source implementation of Silverlight) where the core was C++ but everything was exposed as C to the managed world.
Some platform will have special requirements (e.g. on iOS you'll need to build a static library) but that should not stop you.
Your best bet is to bind things with a tool like Swig
Upvotes: 5