# Problems linking to .dylib

**URL:** <https://forum.juce.com/t/problems-linking-to-dylib/35675>\
**Category:** General JUCE discussion\
**Created:** [October 14, 2019, 2:33pm UTC](https://forum.juce.com/t/problems-linking-to-dylib/35675 "2019-10-14T14:33:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Achder](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/achder/32/5897_2.png) [@Achder](https://forum.juce.com/u/Achder)\
**Post date:** [October 14, 2019, 2:33pm UTC](https://forum.juce.com/t/problems-linking-to-dylib/35675/1 "2019-10-14T14:33:44Z")

</div>

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:

1. Copying the .dylib into the bundle at /Contents/MacOS/
2. Adding an rpath to the program file using  
`install_name_tool -add_rpath @executable_path "my-program-file"`
3. 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:

> <https://github.com/juce-framework/JUCE/blob/master/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp#L947>

So how do I correctly bundle this?

---

<div class="post-metadata">

**Author:** ![Achder](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/achder/32/5897_2.png) [@Achder](https://forum.juce.com/u/Achder)\
**Post date:** [October 14, 2019, 5:23pm UTC](https://forum.juce.com/t/problems-linking-to-dylib/35675/2 "2019-10-14T17:23:19Z")

</div>

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:

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

```

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

```auto
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](https://wincent.com/wiki/%40executable_path%2C_%40load_path_and_%40rpath)
