Juce with new Components inside dynamic libraries



I am developing a JUCE application which can be extended through dynamic libraries. These dynamic libraries can provide any number of new classes inherited from Component.

My problem is that I have random memory errors related to Juce onto the three platforms. I suspect that the problem comes from some static variables that are used inside Juce and that are duplicated between the main program and the plugins. For example, I saw that the set of heavyweightPeers is stored statically in juce_ComponentPeer.cpp. When trying the debug, I fall on the following situation:

        if (c->flags.hasHeavyweightPeerFlag)
            getPeer()-> ...

where getPeer() returned NULL.
For the moment, when initializing the plugins, I forward the value of the MessageManager Singleton. Maybe I should do the same for other variables, are use any initialization function of Juce that I do not know yet …

I never tried the VST plugin mechanism. Maybe, this is related ?

Any suggestion that could help me ?



in that situation I think the best way would be that both your application and the plugin extensions link dynamically against juce and not each one having its own statically linked copy.


You were right, linking juce as a dynamic library fixed the problem.