Initializing Juce in DLL

Hi,

I’m making a DLL in which I want to use Juce, so I was wondering about the things I’m supposed to do to initialise Juce properly in a DLL.
Things are pretty clear when building an app, thanks to the example project: use JUCEApplication class + START_JUCE_APPLICATION (JUCEEditorApplication) macro.
As for the DLL case, I’ve had a look at the VST plugin example, which produces a DLL as well, but I’ve probably missed something, as everything works in my DLL except that I’m using a Timer and timerCallback() is never called.

Juce library is included in my DLL project, and I call initialiseJuce_GUI(), as I’ve found this was done in the VST plugin demo code. However, this isn’t sufficient, so I suppose I missed something else, like creating a thread with a MessageManager or something like that…

So what shall I do to fully initialise Juce in a DLL rather than an app, and get my timer to work?

In linux i do like this, i create a shared message manager:

http://code.google.com/p/juced/source/browse/trunk/wrapper/formats/VST/juce_VstWrapper.cpp#221

you can call SharedMessageThread::getInstance() every time you load your dll, and call SharedMessageThread::deleteInstance() when you free the dll object.

[quote=“kraken”]In linux i do like this, i create a shared message manager:

http://my-trac.assembla.com/juced/browser/trunk/wrapper/formats/VST/juce_VstWrapper.cpp#L221

you can call SharedMessageThread::getInstance() every time you load your dll, and call SharedMessageThread::deleteInstance() when you free the dll object.[/quote]

Thanks. I had seen this piece of code in the vst wrapper, which looked like the kind of thing I needed, but the fact that it was only for a linux build had stopped me from trying it out under Windows. So, as you suggested it, I eventually tried it, but it didn’t seem to help. I added the ShareMessageThread class to my DLL code, and put a SharedMessageThread::getInstance() call in my DLL init function right after the initialiseJuce_GUI() call.

Just in case, I even added a flag set by the SharedMessageThread::run() function and checked by my DLL init function, so the init waits until run() has started before instanciating my class that derives from Timer (the one I’m trying to get its timerCallback() function to be called). But no luck…

I put breakpoints to check that the SharedMessageThread constructor and run() functions were called (as well as the startTimer() function in my Timer-derived class, obviously!) and everything seems to go fine: the message thread seems to start fine at init (and stop fine at exit), but in the meantime, timerCallback() is still not called :frowning:

The message thread doesn’t seem to be aware it’s got to call my timer. Is there’s something extra I need to do?

Am not sure what you are trying to do, but you can use juce as a lib instead of dll in your dll. I do admit it’s not the right way to do but at times wrong ways are as good as right ones :o .

May be the problem would be solved

Regards,
vishvesh

If u r using GUI in the DLL u need to initialize the juce GUI. if u are not doing other than GUI then u need not to call initialize juce GUI.

For example u r working only on File class of the juce then GUI is not used at all.
In other case if you are using popupmenu , document window , component then u have to initialize the juce GUI.