It depends on how you load the shared library. You probably want to use the dlopen command directly with the RTLD_GLOBAL flag. The default is that every plug-in which loads the shared library will have it’s own private copy.
thank you for your reply!
Actually, I also research before.
my plugins are opened by DAW(dopen dynamicallay), but my shared library is opened at first.
so in this case, i also adjust RTLD_GLOBAL? this means i give option at first.
Well it’s loading it before as you’ve linked your plug-in to the shared lib. Then you have no control over RTLD_GLOBAL. You need to not link you plug-in to the shared lib and resolve all symbols at run-time. This might be quite difficult to do. IMHO if you have no good reason to be loading a shared lib in your plug-in then you should probably avoid it. It can cause all sort of problems. For JUCE 4.1, we also put some of the JUCE code in a shared library. A storm of complaints and bugs came in via the forum so we reverted that change only a day later.
Technically you could just use global variables as most hosts will only ever load your shared library once and then simply create several instances of your plug-in. Therefore, there will only be a single instance of your globals regardless of the number of plug-in instances loaded.
However, I personally would not rely on this behaviour. Some DAWs may sandbox plug-ins in the future and break your plug-in. I’d rather rely on IPC.