x


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!

more ▼

asked Mar 25 '12 at 09:55 PM

CherryQu gravatar image

CherryQu
3 1 2 4

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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!

more ▼

answered Mar 26 '12 at 06:36 PM

CherryQu gravatar image

CherryQu
3 1 2 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x337
x74
x74
x20

asked: Mar 25 '12 at 09:55 PM

Seen: 497 times

Last Updated: Mar 26 '12 at 06:36 PM