2013-04-08 131 views
0

即时通讯编程新的编程,我只在PHP和Java编程,但我想了解更多的东西。 这可能不是最好的开始与音频的东西,但我已经知道如何编程工作。Xcode Audiocomponent符号未找到,但无法使用的方法

但是,我想测试一下,从Apple网站获取一些代码,看看会发生什么。 我在我的项目中粘贴了代码的开头,并且出现错误。我真的不知道他们的意思,搜索没有给我任何结果。

那代码:

#include <iostream> 
#include <CoreAudio/CoreAudio.h> 
#include <AudioToolbox/AudioToolbox.h> 
#include <AudioUnit/AudioUnit.h> 

int main(int argc, const char * argv[]) { 
    // insert code here... 
    AudioComponent comp; 
    AudioComponentDescription desc; 
    AudioComponentInstance auHAL; 
    //There are several different types of Audio Units. 
    //Some audio units serve as Outputs, Mixers, or DSP 
    //units. See AUComponent.h for listing 
    desc.componentType = kAudioUnitType_Output; 
    //Every Component has a subType, which will give a clearer picture 
    //of what this components function will be. 
    desc.componentSubType = kAudioUnitSubType_HALOutput; 
    //all Audio Units in AUComponent.h must use 
    //"kAudioUnitManufacturer_Apple" as the Manufacturer 
    desc.componentManufacturer = kAudioUnitManufacturer_Apple; 
    desc.componentFlags = 0; 
    desc.componentFlagsMask = 0; 
    //Finds a component that meets the desc spec's 
    comp = AudioComponentFindNext(NULL, & desc); 
    if (comp == NULL) exit(-1); 
    //gains access to the services provided by the component 
    AudioComponentInstanceNew(comp, & auHAL); 
    return 0; 
} 

,而这些都是错误的,我得到:

Undefined symbols for architecture x86_64: 
"_AudioComponentFindNext", referenced from: 
    _main in main.o 
"_AudioComponentInstanceNew", referenced from: 
    _main in main.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

感谢帮助我!

回答

4

您需要将AudioUnit,CoreAudioAudioToolbox框架添加到您的项目中。请参阅this answer寻求如何做到这一点的帮助。

如果这是您第一次使用C++的经验,那么您肯定会在深度跳跃。祝你好运!

相关问题