On Wed, Mar 9, 2016 at 9:54 PM, Pierre Guillot <guillotpierre6@gmail.com> wrote:
Hi all,

I'm working on a plugin that dynamically loads PD patches. Everything works fine, I even manage the multiple instances issue. You can take a look at it if you want : https://github.com/pierreguillot/Camomile. My problem is that the plugin can't load dynamically the external libraries (I tried with freeverb~ and other libraries and I got : Symbol not found: _s_signal
  Referenced from: /Users/Pierre/GitHub/Camomile/Patches/freeverb~.pd_darwin
  Expected in: flat namespace). 
I don't have any linker flag and I set up this set of macros for the preprocessor:
PD=1
HAVE_UNISTD_H=1
USEAPI_DUMMY=1
HAVE_ALLOCA_H=1
HAVE_LIBDL=1
PD_INTERNAL=1
I use Xcode 7.2.1 with LLVM and OSX 10.9 for the deployment target (required for c++11 support). I going to try on Linux but if anybody has a clue for Mac I would be grateful (I must use Xcode because it's a JUCE project).


libpds has the same problem. If I remember correctly, the problem
is that you have to link your plugin with RTLD_GLOBAL in order
for your externals to see the symbols, but you
don't control how the host loads your plugin. But even if you could
(and you probably can if you make a wrapper plugin that loads your
actual plugin), it wouldn't work very well since you would get lots
of symbol clash when trying to load a second instance of your plugin.

So what I did in libpds was to statically link all externals (in pd extended)
into libpds [1]. Of course, that's not exactly a perfect solution, but it's a lot better
than not being able to use any external.

Maybe it's possible to create your own linker system that somehow fixes
it though, I don't know.

[1] https://github.com/kmatheussen/libpd/blob/master/make.scm