在 JUCE Audio App 中初始化 AudioDeviceManager
Initializing AudioDeviceManager in JUCE Audio App
我正在尝试在我的 MainContentComponent 的构造函数中初始化 AudioDeviceManager 的实例:
MainContentComponent(): deviceManager (getSharedAudioDeviceManager())
其中
AudioDeviceManager& getSharedAudioDeviceManager()
{
if (sharedAudioDeviceManager == nullptr)
{
sharedAudioDeviceManager = new AudioDeviceManager();
sharedAudioDeviceManager->initialise (2, 2, 0, true, String::empty, 0);
}
return *sharedAudioDeviceManager;
}
我的声明是:
AudioDeviceManager& deviceManager;
static ScopedPointer<AudioDeviceManager> sharedAudioDeviceManager;
没有编译错误,但我有运行时错误,其中编译器告诉我:
Undefined symbols for architecture x86_64:
"MainContentComponent::sharedAudioDeviceManager", referenced from:
MainContentComponent::getSharedAudioDeviceManager() in MainComponent.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
完全迷路了。帮助!
您需要在 class 声明之外定义您的静态成员,如下所示...
ScopedPointer<AudioDeviceManager> MainContentComponent::sharedAudioDeviceManager;
此外,这是一个 linktime 错误,而不是 runtime 错误。
我正在尝试在我的 MainContentComponent 的构造函数中初始化 AudioDeviceManager 的实例:
MainContentComponent(): deviceManager (getSharedAudioDeviceManager())
其中
AudioDeviceManager& getSharedAudioDeviceManager()
{
if (sharedAudioDeviceManager == nullptr)
{
sharedAudioDeviceManager = new AudioDeviceManager();
sharedAudioDeviceManager->initialise (2, 2, 0, true, String::empty, 0);
}
return *sharedAudioDeviceManager;
}
我的声明是:
AudioDeviceManager& deviceManager;
static ScopedPointer<AudioDeviceManager> sharedAudioDeviceManager;
没有编译错误,但我有运行时错误,其中编译器告诉我:
Undefined symbols for architecture x86_64:
"MainContentComponent::sharedAudioDeviceManager", referenced from:
MainContentComponent::getSharedAudioDeviceManager() in MainComponent.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
完全迷路了。帮助!
您需要在 class 声明之外定义您的静态成员,如下所示...
ScopedPointer<AudioDeviceManager> MainContentComponent::sharedAudioDeviceManager;
此外,这是一个 linktime 错误,而不是 runtime 错误。