Using OSC in a console application


Hi, when trying to use the OSC classes in a console app I’m getting an assertion on the following line:

MessageListener::MessageListener() noexcept
// Are you trying to create a messagelistener before or after juce has been intialised??
jassert (MessageManager::getInstanceWithoutCreating() != nullptr);

Is there some basic JUCE init code that needs to be called that isn’t getting done by default in a console program?



You can use OSC in console application, but then you must implement a subclass of JUCEApplication. For example, something like this will work:

#include "../JuceLibraryCode/JuceHeader.h"

class ConsoleApplication : public JUCEApplication
    const String getApplicationName() override    { return "ConsoleApplication"; }
    const String getApplicationVersion() override { return "0.0.1"; }
    void initialise (const String& /*commandLineParameters*/) override
        // Start your app here
        DBG ("initialise");
    void shutdown() override {}


You need to remember that you should not block the message thread. So when using OSC, you should register the OSC callbacks you want in the initialise method and maybe start a timer to send stuff.


Hi, great - thanks for the info.