I need to link multiple AudioProcessor classes from a static library into a parent AudioProcessor, and it took me a while to figure out, so here is what I did, in case it saves someone else time, and/or to learn how I should have done it :
I am building for iOS on a Mac using Xcode et al. It almost “just works” to link from the static library created by the “Shared Code” target of a plugin Xcode project, as generated by Projucer. However, the problem is that every plugin defines createPluginFilter() which returns an AudioProcessor*, and we only want one createPluginFilter() function defined in the one parent plugin. I thought about removing this function from the static library in a postbuildScript (maybe ar
can do it), but right now my solution is as follows:
-
Copy myPlugin.jucer to nestedPlugin.jucer
[wart: must be done again after the main .jucer file changes] -
Edit nestedPlugin.jucer to change myPlugin to myNestedPlugin in the
name
fields andbundleIdentifier
field. Also insertdefines="STATIC_LIBRARY"
in the<JUCERPROJECT...>
tag. All of this is near the top of the .jucer file. -
In
PluginProcessor.cpp
, near the end, say something like:
#ifdef STATIC_LIBRARY
extern "C" AudioProcessor* JUCE_CALLTYPE createMyNestedPlugin()
#else
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
#endif
{
return new MyAudioProcessor();
}
Note that only the Shared Code target will compile with STATIC_LIBRARY defined, since otherwise the function createPluginFilter() is required for compilation.
The wart could be removed by supporting defines
on a per-target basis.
Thanks for any better ideas!
Julius