How do I call unmanaged functions in C from Unity if I don't have a .bundle? (Mac)

Hi all,

I am on Mac.

I have a bunch of c source code (.c && .h).

I have a static library (.a).

I want to use that .a library from within Unity.

I looked into Unity’s documentation for plug-ins, which says for PC and Mac stand alones, .bunlde files seem to be the only solution. All example plugin-in projects that Unity give have .bundle plugins.

But I have seen prime31 plugins using .a library in Unity!

Anyone has a clue how they did that?

Many, many thanks!

PS: In case some of you wonder why I have the source code but not the bundle. I am trying to build a bundle from those .c and .h but hasn’t succeeded yet. The source code was compiled with make tools, but I don’t know anything else that could build a bundle except for Xcode. So I guess I have to use Xcode to build my bundle. My problem is when I tried to build it with Xcode I get millions of errors saying that I have duplicate main entries. I checked the source code and found that it does have duplicate main()s because the source code has lots of utilities that come with it. I tried deleting those utilities but the same error doesn’t go away…

I am planning to ask this question somewhere else because this does not seem very Unity-related. But if someone here happens to know the answer, please don’t hesitate – let me know!

Thanks!

Okay I got an email from the prime31 people. It’s impossible to do that.

Unity does not build an Xcode project for OSX, so you can’t link a static library. Unity does build an Xcode project for iOS, that’s how the prime31 developers could use the .a library(in Xcode, not in Unity)

To sum up, to use unmanaged code in Unity on MacOS, the only correct way is to build a bundle from your source code and then import it to Unity. Just like their documentation said!