Achder
October 14, 2019, 2:33pm
1
Hi,
I’m trying to add a .dylib to my project that in turns depends on several other libs. So far I can’t get it working in any DAW.
What I’m doing is:
Copying the .dylib into the bundle at /Contents/MacOS/
Adding an rpath to the program file using
install_name_tool -add_rpath @executable_path "my-program-file"
This works for the standalone version, but plugins won’t load.
Before this I simply added a sym-link of the .dylib to /usr/local/lib. Same results.
In the JUCE plugin host I see it having trouble with this line:
if (CFURLRef url = CFURLCreateFromFileSystemRepresentation (nullptr, (const UInt8*) utf8, (CFIndex) std::strlen (utf8), file.isDirectory()))
{
bundleRef = CFBundleCreate (kCFAllocatorDefault, url);
CFRelease (url);
if (bundleRef != nullptr)
{
CFErrorRef error = nullptr;
if (CFBundleLoadExecutableAndReturnError (bundleRef, &error))
{
using BundleEntryProc = bool (*)(CFBundleRef);
if (auto proc = (BundleEntryProc) getFunction ("bundleEntry"))
{
if (proc (bundleRef))
return true;
}
else
{
So how do I correctly bundle this?
Achder
October 14, 2019, 5:23pm
2
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