2013-04-08 132 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++的經驗,那麼您肯定會在深度跳躍。祝你好運!

相關問題