I recently edited our juce-1.45 source to export all symbols when built as a static library, instead of just when built as a dll. We build our audio engine as a dll on windows and want to be able to link the static library into our engine once and use our juce symbols from the juce audio plugin wrapper code as well. The alternatice is to link the juce static library to our engine, and then again to the audio plugin target, which creates duplicate symbols and assertions on duplicate static data such as MessageManager::instance.
Basically this just took a little macro mangling and adding JUCE_API to some function declarations to get the unresolved symbols in the vst and rtas wrapper targets to be resolved to the symbols linked into our engine dll.
I can send a patch to you to explain it a little better, but what it be possible to add this feature to the source distribution so we can make clean upgrades?
It would be great if you could explain in detail, how you managed to do it.
Interesting - I’d be keen to see how much hackery was involved!
I took a shortcut to accomplish much the same thing, using 1.46. I changed the JUCE DLL Debug config to make the output a static lib instead of a DLL. Then in my own DLL project, I define JUCE_DLL_BUILD and link in the static lib. You’ll need to define DONT_AUTOLINK_TO_JUCE_LIBRARY and specify the desired one.
I also needed to add a JUCE_API specifier to the MidiBuffer::Iterator class, and added JUCE_PUBLIC_FUNCTION to the declarations (there are two, and one in the VST wrapper) of juce_callAnyTimersSynchronously(). That’s it!
Not too much hackery…
I tried to build a static lib of JUCE MODULES and integrated to my own DLL project. I have JUCE_DLL_BUILD enabled but it gives me lot of linker errors
"Error LNK2001 unresolved external symbol “void __cdecl juce::juceDLL_free(void *)” (?juceDLL_free@juce@@YAXPEAX@Z)"
"Error LNK2001 unresolved external symbol “void * __cdecl juce::juceDLL_malloc(unsigned __int64)” (?juceDLL_malloc@juce@@YAPEAX_K@Z) "
Do you know why this happens ?