writing a C++ library for both C# and Objective C++

I'm in the feasibility stage of a project and I want to know if it is possible to create a library in C++ that can be utilized by both C# and Objective C.

Ideally I want to be able to create applications for the Mac OS and Windows environments without having to maintain two seperate code sets.

Your advice on this matter is greatly appreciated.

many thanks
Yes, as long as you keep your code as pure c++ and don't use any OS specific API calls. There are loads of open source libraries like this, mostly written in c.
Last edited on
When you say library, are you talking about a static library or a DLL?

In the latter case, the main two possibilites for C# are:
- use PInvoke can call exported static class member functions or regular function
- write a mixed-mode wrapper assembly in C++/CLI

When it comes to Objective C, this is outside of my skillset. But this thread suggests that you can use C-linkage but not C++, due to name mangling. So you'd need to expose your C++ functionality via a C API.


So it sounds like a DLL /.dylib with a C-style API should be accessible from C# and Objective C.


Last edited on
Topic archived. No new replies allowed.