Dynamic linking problems with the fmod API

Hi, I’ve been trying to link the fmod API with JUCE for a GUI application. I did this through setting my ‘external libraries to link’ to the required .dylibs.Screenshot 2020-05-08 at 10.00.38

I then set the header and library search paths to the places where the header files and .dylibs were. Screenshot 2020-05-08 at 10.18.56

I thought this would be the correct way to set it up. The project can build however it very quickly runs into this error:

dyld: Library not loaded: @rpath/libfmodstudioL.dylib

Referenced from: /FMODJUCETEST/Builds/MacOSX/build/Debug/FMODJUCETEST.app/Contents/MacOS/FMODJUCETEST

Reason: image not found

Am I not setting up the projucer right to link these libraries?
Thanks,

The project links successfully, so the linker flags are correct :+1: But when the app runs, it looks for those .dylibs inside its .app bundle. So you also have to copy the .dylib files into FMODJUCETEST.app/Contents/MacOS/. You can do this by hand to see if that fixes the problem. If so, you can automate this step: Write a Post-Build Shell Script in Projucer’s MacOSX exporter. The script should copy the files:

cp "${PROJECT_DIR}/dependencies/core/lib/*.dylib" "${BUILT_PRODUCTS_DIR}/FMODJUCETEST.app/Contents/MacOS/"
cp "${PROJECT_DIR}/dependencies/studio/lib/*.dylib" "${BUILT_PRODUCTS_DIR}/FMODJUCETEST.app/Contents/MacOS/"

Ok, had a go manually moving the files and still got the error unfortunately

Could it have something to do with rpath and what that is set as?

Have a look using otool -l your_binary
This will list all libraries the binary depends on. Unfortunately ofthen build scripts have the absolute path to the library set here. There is a tool called install_name_tool to change that setting. @rpath is a symbol that is replaced with a search path, which is the best way to do it.
Best to look up the rpath meaning on an official site, like this:
https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html

Thanks for the help. So after doing some research - @rpath is a path which is set in the target executable settings. So I am guessing I need to add a run path search path to the list in the target executable settings. Is there any way to do this through JUCE?

Resolved by adding run path search paths to the library locations through using the LD_RUNPATH_SEARCH_PATHS custome Xcode flag