问题
We have developed a custom audio unit and audio unit hosting application. We are trying to register the custom audio unit dynamically from the application. Below code snippet is used to register audio unit dynmaically. (this code snippet is mentioned in Apple technical note Technical Note TN2247)
#include <AudioUnit/AudioComponent.h>
extern AudioComponentPlugInInterface*
MyExampleAUFactoryFunction(const AudioComponentDescription *inDesc);
OSStatus RegisterMyExampleAudioUnit()
{
// fill out the version number for the AU
UInt32 theVersion = 0x00010000;
// fill out the AudioComponentDescription
AudioComponentDescription theDescription;
theDescription.componentType = kAudioUnitType_Effect;
theDescription.componentSubType = 'EXAU';
theDescription.componentManufacturer = 'MYCO';
theDescription.componentFlagsMask = 0;
// Use the flag to indicate that this AudioComponent is Sandbox Safe
theDescription.componentFlags = kAudioComponentFlag_SandboxSafe;
// call AudioComponentRegister()
return AudioComponentRegister(&theDescription, CFSTR("My Company: MyExampleAU"),
theVersion, MyExampleAUFactoryFunction);
While compiling the audio unit hosting application, we are getting below linker error.
Undefined symbols for architecture i386:
"_MyExampleAUFactoryFunction", referenced from:
Can any one help me solve this issue.
回答1:
I ran into this issue too, my project had only C and Objective-C code. It helped, to create a single cpp class and add it too the project. I do not know what the deeper cause inside the linker is.
来源:https://stackoverflow.com/questions/14705405/audio-units-dynamic-registration