I’m running into some build problems when compiling JUCE as a DLL. Here’s a list of issues I ran into in no particular order:
-Unresolved external linking errors when building a JUCE demo app under MSVC or Borland. eg. Image::BitmapData, AudioFormatWriter::ThreadedWriter and some others. It seems __declspec(dllexport) doesn’t quite do the same thing as GCC’s __attribute(visibility). Nested classes do not get export visibility for the former. The unresolved errors all seem to be referring to nested classes that’s not visible from outside the JUCE DLL.
-Ambiguous new/delete overload under all compiler toolchains I tried: MSVC, Borland, Mingw-gcc4.5.2 when building JUCE demo. This seems related to this issue but the relevant headers contains a deprecated comment for the UseDebuggingOption. I’m not sure what the correct fix is but commenting out the following in juce.h seems to temporarily fix the issue:
#ifdef JUCE_DLL #undef JUCE_LEAK_DETECTOR(OwnerClass) #define JUCE_LEAK_DETECTOR(OwnerClass) #endif
While the cause is obvious the fix isn’t, at least not for me. The ambigity issue comes up because the above macro will nullify user derived classes to not have overloaded new and delete. If those classes multi-inherit from juce classes that do overload new/delete than this problem comes up.
-In juce_String.h MSVC does not like
template <class charT, class traits> JUCE_API std::basic_ostream <charT, traits>& JUCE_CALLTYPE operator<< (std::basic_ostream <charT, traits>& stream, const String& stringToWrite)
when JUCE_API = __declspec(dllimport) and I can see why it complains. DLL importing a template function in this context is non-sensical. This problem does not come up for mingw-gcc because it uses __attribute(visibility) instead and JUCE_API defines to nothing for the client program. Mingw-gcc also complains with the same error had it used __declspec(dllimport) in the same fashion.
One last note, when building JUCE as a DLL I have JUCE_DLL_BUILD=1 and JUCE_DLL=1 defined. For building the demo apps I have only JUCE_DLL=1 defined. Is this the proper setup? I was unable to find any mention of how this should be done in the docs when building and using JUCE as a DLL.
Are any of these known issues and how should they be fixed?