DLLNotFoundException, trying to build bundle from .a library on OSX

Hi all, I think I’ve met with a tricky problem.

I am on Mac OS Lion and I want to use Xcode 4 to build a bundle plugin for Unity Pro. The c code that I want to reuse is a bunch of .h and .c files that are supposed to be build by the make tools. I tried to build a Cocoa bundle with the C source files but failed. I then tried to use the .a library that make builds and I build that .a file into a bundle in Xcode. This time the build succeeded but when I was trying to call a function defined in the C source code, Unity gives me a runtime DLLNotFoundException.

Can someone please help me?

Here is detailed description of what I did:

  1. I built a Cocoa bundle. The only effective component is a library called libccn.a so I guess in theory whatever function defined in the header ccn.h should be available for me after I imported the plugin.
    This is the definition of the function I called in ccn.h file:
    int ccn_run(struct ccn *h, int timeout);

  2. I put the bundle in Unity’s Plugin folder

  3. This is my C# script

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

    public class PluginScript : MonoBehaviour {

    public struct CCN
    public static extern int ccn_run(ref CCN ccn, int timeout);
    void Start () {
    	CCN ccn = new CCN();
    	ccn_run(ref ccn, 1);


Here is a summary of my questions:

  1. I thought Unity can’t use .a libraries directly, am I right?

  2. Can Unity use bundles built from .a libraries? Has anyone done that before?

  3. If Unity can recognize bundles built from .a library, could anyone give me some hint about what I am doing wrong now?

Many thanks in advance!

Its gonna be a bit long so I ll just post it as an answer rather than a comment

Firstly, I am not an expert so I will try my best to understand and tell you how they have used it in the plugin.

They have the .a file here
Assets → Editor → GameCenter → libGameCenterPlugin.a

Then in
Plugins–>GameCenter they have a c# script with several [DllImport (“__Internal”)]

about which you can read here


Then finally they have given this instruction

After make Unity XCode project link project with library “Assets/Editor/GameCenter/ libGameCenterPlugin.a”

(basically just drag it into Xcode)

I dont know if I can help more.

I told you what I understood

IF YOU DO WANT THE C# SCRIPT GIVE ME YOUR EMAIL. Even though it has nothing it is copyrighted and I dont want to get into trouble by posting it here.##