fluid~ doesn't load on OSX

Here's the error message that I get in the console:

/Applications/Pd-l2ork-full-x86_64-20170106.app/Contents/Resources/app.nw/extra/fluid~/fluid~.pd_darwin: dlopen(/Applications/Pd-l2ork-full-x86_64-20170106.app/Contents/Resources/app.nw/extra/fluid~/fluid~.pd_darwin, 10): Library not loaded: /usr/local/lib/libgthread-2.0.0.dylib
  Referenced from: /Applications/Pd-l2ork-full-x86_64-20170106.app/Contents/lib/libfluidsynth.1.dylib
  Reason: image not found
 fluid~ FluidR3_GM.sf2
... couldn't create

As otool shows, libfluidsynth.1.dylib is linked against some GTK libraries not usually installed on the Mac:

$ otool -L libfluidsynth.1.dylib 
libfluidsynth.1.dylib:
	@executable_path/../../../lib/libfluidsynth.1.dylib (compatibility version 1.0.0, current version 1.5.2)
	/usr/local/lib/libgthread-2.0.0.dylib (compatibility version 4601.0.0, current version 4601.0.0)
	/usr/local/lib/libglib-2.0.0.dylib (compatibility version 4601.0.0, current version 4601.0.0)
	@executable_path/../../../lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.4.0)
	/usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
	/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI (compatibility version 1.0.0, current version 73.0.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 728.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1253.0.0)

In particular, note these:

	/usr/local/lib/libgthread-2.0.0.dylib (compatibility version 4601.0.0, current version 4601.0.0)
	/usr/local/lib/libglib-2.0.0.dylib (compatibility version 4601.0.0, current version 4601.0.0)

The second one is actually included in /Applications/Pd-l2ork-full-x86_64-*.app/Contents/lib, while the first one is missing. If I copy it there, dyld still complains since it will look for the libraries in the wrong place. This can be fixed by editing libfluidsynth with install_name_tool as follows:

install_name_tool -change /usr/local/lib/libglib-2.0.0.dylib @executable_path/../../../lib/libglib-2.0.0.dylib -change /usr/local/lib/libgthread-2.0.0.dylib @executable_path/../../../lib/libgthread-2.0.0.dylib libfluidsynth.1.dylib

fluid~ then loads and works all right.

I've attached a suitably edited libfluidsynth.1.dylib below. To fix the bug, make sure that the corrected libfluidsynth as well as libgthread is included in the application bundle, then everything should be all right.

libfluidsynth.1.dylib