Skip to main content
Legend
December 14, 2015
Answered

How to properly use a .dylib in a plugin on OSX?

  • December 14, 2015
  • 1 reply
  • 6148 views

Hello All,

So after using the much appreciated help here on the forums, I was successful at loading a third-party DLL that I needed to use in my plugin on Windows.  Now, I'm moving onto OSX and have a .dylib file that is effectively the equivalent of the DLL in OSX.  My question is how do I properly load the .dylib on OSX for my plugin to work within AE?

Many thanks for your time and help!


Best,
Arie

This topic has been closed for replies.
Correct answer

I don't need it at runtime, but I was getting the same error from AE about my plugin being invalid.  I essentially added the .dylib file to the list of dynamic libraries under the "Link Binary With Libraries" heading in the "Build Phases" tab of my bundle target.  Then I added the path to the .dylib file under the "Library Search Paths" setting under the "Build Settings" tab of my target.

I do have a header file for the .dylib, and I placed it in my plugin's code.  XCode built the plugin successfully, but when I went to apply it on a layer in AE, it just gave me an error that said "Could not find entry point", then it said "Invalid Filter".  So, that was the same error I was receiving on the windows side.  Is there anything I'm missing to make sure the .dylib loads correctly if I don't want to do run time loading?


Ah, ok, that should make things easier. So where did you put your dylib file? Same as with Windows, it needs to be in a location referenced in the path environment variable or in the location of the calling application. Easiest thing to test will probably if you put it in /usr/lib or /usr/local/lib (for global access) or ~/lib for the current user only.
See also here: Using Dynamic Libraries

1 reply

December 14, 2015

Hi Arie,

well, it depends on how much you know already and where you are having problems. :-)

A .dylib is basically nothing more than a renamed .so (shared object) object file from the Linux world

The equivalent command for "LoadLibrary" on MacOS is "dlopen", and you can access function pointers/symbols with "dlsym", and instead of "FreeLibrary" you use "dlclose".

Check these links for some info:

Dynamic loading - Wikipedia, the free encyclopedia

OS X ABI Dynamic Loader Reference

http://stackoverflow.com/questions/2339679/what-are-the-differences-between-so-and-dylib-on-osx

Legend
December 14, 2015

But how do you reference the .dylib file?  Do we just include it in the bundle of the plugin and reference it somehow from there?

Correct answer
December 15, 2015

I don't need it at runtime, but I was getting the same error from AE about my plugin being invalid.  I essentially added the .dylib file to the list of dynamic libraries under the "Link Binary With Libraries" heading in the "Build Phases" tab of my bundle target.  Then I added the path to the .dylib file under the "Library Search Paths" setting under the "Build Settings" tab of my target.

I do have a header file for the .dylib, and I placed it in my plugin's code.  XCode built the plugin successfully, but when I went to apply it on a layer in AE, it just gave me an error that said "Could not find entry point", then it said "Invalid Filter".  So, that was the same error I was receiving on the windows side.  Is there anything I'm missing to make sure the .dylib loads correctly if I don't want to do run time loading?


Ah, ok, that should make things easier. So where did you put your dylib file? Same as with Windows, it needs to be in a location referenced in the path environment variable or in the location of the calling application. Easiest thing to test will probably if you put it in /usr/lib or /usr/local/lib (for global access) or ~/lib for the current user only.
See also here: Using Dynamic Libraries