Possible Dynamic Library Bug

Hey guys,

I wanted to share an issue I ran into. I made a version of a project into a dynamic library build to include inside another project. Everything worked except a DocumentWindow I was using in the project. I then compiled the project as a static library and included it that way to test and the DocumentWindow worked just fine.

Basically, when built as a dynamic library, I can interact with the DocumentWindow, calling a bunch of functions on it like setting the top left corner position and such, with no crashes jasserts, complaining or anything. I just don’t see the window.

Working on a Mac using the tip of the development branch updated from a few weeks ago.

Can you reproduce this with a simple example? I’ve built a JUCE .dylib on macOS with a single .cpp file containing the following:

#include <JuceHeader.h>

extern "C" JUCE_API void JUCE_CALLTYPE openWindow()
    ScopedJuceInitialiser_GUI gui;
    struct Window  : public DocumentWindow
             : DocumentWindow ({}, Colours::hotpink, DocumentWindow::allButtons)
            setUsingNativeTitleBar (true);
            setResizable (true, true);
            centreWithSize (500, 500);
            setVisible (true);
    Window w;
    Process::setDockIconVisible (true);

Then I’m loading the library and calling openWindow from a simple console app:

int main (int argc, char* argv[])
    DynamicLibrary lib ("DllTest.dylib");
    jassert (lib.getNativeHandle() != nullptr);
    auto* fPtr = reinterpret_cast<void(*)()> (lib.getFunction ("openWindow"));
    jassert (fPtr != nullptr);
    if (fPtr != nullptr)
    return 0;

And everything is working as expected.