- Home /
Cannot make native plugin working on OS X.
Hi, I am trying to make working native plugin on OS X.
If I build it using Xcode as bundle and put it to the Assets/Plugins directory it cannot be loaded by the application throwing System.DllNotFoundException. I tried with and without "lib" prefix with no luck. I see the following messages in the log preceding the exception:
Fallback handler could not load library /Applications/UgCS/ugcs-client/ugcs-client.app/Contents/Frameworks/MonoEmbedRuntime/osx/./libucs_video.dylib
Fallback handler could not load library /Applications/UgCS/ugcs-client/ugcs-client.app/Contents/Frameworks/MonoEmbedRuntime/osx/./libucs_video.so
Fallback handler could not load library /Applications/UgCS/ugcs-client/ugcs-client.app/Contents/Frameworks/MonoEmbedRuntime/osx/./libucs_video.bundle
Fallback handler could not load library /Applications/UgCS/ugcs-client/ugcs-client.app/Contents/Frameworks/MonoEmbedRuntime/osx/libucs_video
So I tried to build just the dynamic library and put it as ugcs-client.app/Contents/Frameworks/MonoEmbedRuntime/osx/./libucs_video.dylib. And it partially works - the exception is not longer thrown and I'm able to call functions from the plugin in the application scripts. However there is still a problem - UnityRenderEvent() callback is not called by the Unity so the plugin is unable to do any rendering. Also I am confused by this way because it obviously is not the one described in Unity documentation.
I have verified that the plugin itself and all its dependencies have the correct architecture (the one for which the application is compiled), and otherwise the partially working workaround would not work.
Does anyone could help with this problem?
Are you still calling GL.IssuePluginEvent
from your c# code?, could you post your c# and maybe there's a problem there?
I have a plugin with the line extern "C" void EXPORT_API UnityRenderEvent(int eventID);
(C++) and that's all I need in my plugin code (for osx and windows) for it to get called
Yes, I definitely call it in the following manner:
IEnumerator
Start()
{
yield return StartCoroutine("OnFramesEnd");
}
private IEnumerator
OnFramesEnd()
{
while (true) {
/* Wait until all frame rendering is done. */
yield return new WaitForEndOfFrame();
GL.IssuePluginEvent(<some_id_here>);
}
}
Also forgot to mention that UnitySetGraphicsDevice() is also not called.
It's possible that the "unused" functions/symbols are being stripped at compile time. You could check those symbols (UnitySetGraphicsDevice and UnityRenderEvent) are still in the .dylib after compiling with ter$$anonymous$$al
https://developer.apple.com/library/mac/documentation/Darwin/Reference/$$anonymous$$anPages/man1/nm.1.html https://developer.apple.com/library/mac/documentation/Darwin/Reference/$$anonymous$$anpages/man1/symbols.1.html
If that's the case, there is a build option to strip symbols you can turn off (Not sure exactly where this is offhand, but should be easy to find with the filter :)
Both functions are exported:
$ nm libucs_video.dylib | grep UnitySetGraphicsDevice
00024710 T _UnitySetGraphicsDevice
$ nm libucs_video.dylib | grep UnityRenderEvent
0000af20 T _UnityRenderEvent
Also I did not heard that such behavior is possible because all source files are compiled separately and the compiler does not know which functions will be used from other sources (as well as from library users).
Your answer
