Problems linking to .dylib

Oh okay, I found the solution by myself.
In case of a plugin, @executable_path resolves to the DAWs executable. @loader_path resolves to the plugins path when its loaded inside a DAW.

So I just switched the install name of the lib back to @rpath/mylib.dylib using:

install_name_tool -id @rpath/mylib.dylib mylib.dylib

And then I add two new rpaths to the resulting executable using:

install_name_tool -add_rpath @executable_path/../Frameworks
install_name_tool -add_rpath @loader_path/../Frameworks

This way the executable looks in these two directories for the .dylib. First one is for standalone use, second one for plugins.

Last but not least, copy the actual .dylib into the bundle under Contents/Frameworks/ so it can be found.

See also:
https://wincent.com/wiki/%40executable_path%2C_%40load_path_and_%40rpath

3 Likes