Christian Stavro
Christian Stavro

Reputation: 155

Xamarin, C++, Cocos2D-X and Visual Studio

Ok, so I currently have an iOS app that mixes iOS user interface elements and Cocos2d-x (Cocos2d C++).

I got a rough port working for Android with Java/JNI when I stumbled across Xamarin and their Visual Studio plugin. Their documentation mentions that C++ code can be used along with it, but I'm failing to find any example Xamarin projects that demonstrate this functionality.

Does Xamarin support adding C++ source to their Visual Studio projects? And, if so, does it allow for seamless compilation and debugging of that source along with the C#?

Also, are there any examples of this functionality?

Essentially I would love to use the portability of Xamarin C# User Interface stuff, along with the ton of C++ Cocos2d-x code I already have written.

Please respond with questions if I am being unclear.

Upvotes: 4

Views: 1779

Answers (2)

Andy Dent
Andy Dent

Reputation: 17969

Researching this in 2014:

  • The generic approach to bundling C++ code with a different language is to provide a C function call interface. This usually means your C++ code contains a factory function to return a generic pointer to your C++ object and that's passed around as a void* into the C wrappers. Just about every environment on the planet can invoke standard C functions as this is necessary to get to most low-level operating system functions.
  • This Xamarin Forums Jan 2014 article discusses using NDK to compile after generating wrappers with CppSharp
  • Skyscanner did a two-part series on cross-platform libraries, with an intro to the tools in Feb 2014 followed by the C++ answer which has a lot of detail that may help with using C++ from Xamarin (all the crufty NDK bits).

Upvotes: 3

sshaw
sshaw

Reputation: 266

I'm not sure that this exactly answers your questions, but maybe a place to start from http://tirania.org/blog/archive/2011/Dec-19.html

Upvotes: 1

Related Questions