- Home /
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:
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);
I put the bundle in Unity's Plugin folder
This is my C# script
using UnityEngine; using System; using System.Collections; using System.Runtime.InteropServices;
public class PluginScript : MonoBehaviour {
[StructLayout(LayoutKind.Auto)] public struct CCN { } [DllImport("CCNxB")] 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:
I thought Unity can't use .a libraries directly, am I right?
Can Unity use bundles built from .a libraries? Has anyone done that before?
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!
I had bought a gamecenter plugin. It had a .a library plugin.
I even had to import it in xcode to link it to the library. (Drag it into xcode)
So surely unity can undertand them.
Great! But could you give me more hint about how to import .a library into Unity then? When it is a .bundle plug-in, I can use [DllImport]... But I don't know what to do with a .a library...
Answer by GameFreak · Mar 23, 2012 at 08:20 PM
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
http://unity3d.com/support/documentation/Manual/Plugins.html
Then finally they have given this instruction
Build 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.
heers
Rishab.
Also I don't quite understand the instruction they gave (Build After make Unity XCode project link project with library "Assets/Editor/GameCenter/ libGameCenterPlugin.a")
You said you dragged the .a library into Xcode. But are you supposed to build an Xcode project? Isn't the library already in Unity? I thought if the static library is already in Unity and they already have a C# script that imports it, you won't need to build any Xcode project...
So could you tell me more about that? Thanks a lot!
Tickmark my answer so that the question is closed.
I have sent you email lets talk there.
Your answer
![](https://koobas.hobune.stream/wayback/20220613065433im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity fails to include .bundle for native code plugin when building Intel Mac player. 0 Answers
What to choose to make .bundle plugin in XCode? 1 Answer
Why doesn't my bundle build for Mac OS X using Xcode 4.5? 1 Answer
Does Unity 5 support OSX i386 plugins (without x86_64)? 0 Answers
FileNotFoundException: Could not load file or assembly 0 Answers