Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7698393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:13:55+00:00 2026-05-31T22:13:55+00:00

I am on Mac. I have a bunch of C source code ( .c

  • 0

I am on Mac.

I have a bunch of C source code (.c and .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 (http://unity3d.com/support/documentation/Manual/Plugins.html), which says for PC and Mac stand alones, .bundle 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?

Here is all that I can tell from analyzing prime31 plugin:

(1) they put their .a library in Unity’s Editor folder

(2) they have a C# script which contains lots of [DllImport ("__Internal")]

I tried to do the same:

(1) I wrote a simple hello_world.c in Xcode and built a .a library. I put the libhelloworld.a in Asset/Editor

(2) I then wrote a C# script that looks like this:

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;

public class testlib : MonoBehaviour {
    [DllImport ("libhelloworld")]
    static public extern System.String helloworld();
}

(3) Then I wrote a test script:

using UnityEngine;
using System.Collections;

public class test : MonoBehaviour {

    // Use this for initialization
    void Start () {
        print(testlib.helloworld());
    }


}

(4) By doing so I get a runtime error:

DllNotFoundException: libhelloworld
test.Start () (at Assets/Script/test.cs:8)

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:13:56+00:00Added an answer on May 31, 2026 at 10:13 pm

    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!

    I think I will try to build a bundle from source code or try to build a bundle from the .a library that I am now able to build, though Mac OS documentation says it’s pointless:

    Note: Some Xcode targets (such as shell tools and static libraries) do
    not result in the creation of a bundle or package. This is normal and
    there is no need to create bundles specifically for these target
    types. The resulting binaries generated for those targets are intended
    to be used as is.

    I may post another question and if that question got answered, I will include a link here…

    Alright I am coming back to edit:

    Finally I built a bundle from a .a static library and was able to call functions of the library from Unity. Here is how I did: How to organize C source file previously compiled by GCC Make and build them into an Xcode bundle? I have a Duplicate Symbol _main Error

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mac with a custom PHP 5 install that built from about
I have Perl on Mac, Windows and Ubuntu. How can I tell from within
I have a bunch of code in an iOS project (named MyLibs) I re-use
I have a project that targets both Mac OS X 10.4 and 10.5, where
We have a set of Mac machines (mostly PPC) that are used for running
I have a software that runs on mac (using terminal program) the program is
I have a very simple Mac Cocoa app that just has a Web View
I have known that If you define a bunch of @ NSString objects in
I have a bunch of text files that are encoded in ISO-8851-2 (have some
I am using GitHub for Mac, and have bunch of changes in my branch.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.