General: I have a standards compliant C++ API that uses Boost libraries that I would like to support as a native, statically linkable library on Windows, OS X, and Linux, and that I’d like to wrap for .NET on Windows and Mono on OS X and Linux.
Specifics: Currently I have it compiling natively for all platforms – this followed from using standard C++ and Boost. I also got it to compile and run for C++/CLI on Windows, but I was forced to use the Boost .DLLs. The next step I’m not sure where to begin with as I’ve never tried to use shared libraries on *nix systems. I know Boost provides shared libraries on Linux (and I’ll presume the same is true on OS X), but will these just work auto-magically with my Visual Studios compiled C++/CLI executable, or do I need to do some work? There’s no C++/CLI compiler for MonoDevelop, but supposedly Visual Studios compiled CLI will work just fine… it’s the dynamically linked libraries that are confusing me.
C++/CLI assemblies will only load on Mono if they are compiled with
/clr:pure. A mixed mode C++/CLI assembly (which is any assembly using native code, ie: boost) will not run on non-Windows platforms.Your best option is to provide a C API, and use P/Invoke to call into the native code. This is portable across platforms, provided you include the same C API on both platforms.