> >> I link with "ld -shared -Bsymbolic -lc -lm -o $@", but YMMV. > > I did that, but when linking with the alsa library from within the plugin, > > alsa only works when I load the plugin with RTLD_GLOBAL, and I would > > like to know why. > > If you don't specify RTLD_GLOBAL when loading your plugin, the libasound > symbols are not made globally available to other dl_open()'ed modules. > Specifically, they are not available to routines dynamically loaded by > libasound (in snd_pcm_open()). Thus, loading your plugin succeeds, but > libasound fails to load its own plugins.
ah, I think I get it. When loading a library with dlopen() from within a library loaded with dlopen() it can only use symbols from that library if the first one is loaded with RTLD_GLOBAL. Then my question is, wouldn't it be possible for the ALSA library to not use global symbols from its dynamically loaded libraries? That would make loading from a library loaded with RTLD_LOCAL possible right? I guess it is not really a problem to have my plugin loaded with RTLD_GLOBAL though. --martijn
