xcode - 找不到Xcode音频组件符号,并且某种程度上无法使用方法

标签 xcode audio core-audio

我是C++编程的新手,我只用php和Java编程,但我想学习更多。
从音频开始也许不是最好的选择,但我已经知道编程的工作原理。

但是,我想进行测试,从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)

谢谢你的协助!

最佳答案

您需要将AudioUnitCoreAudioAudioToolbox框架添加到您的项目中。有关如何执行此操作的帮助,请参见this answer

如果这是您第一次使用C++,那么您肯定会步入深渊。祝好运!

关于xcode - 找不到Xcode音频组件符号,并且某种程度上无法使用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15884213/

相关文章:

c# - (Xamarin)将音频文件从Wav转换为Flac for(Google)Cloud Speech API

objective-c - 实时获取 macOS 输出设备音频缓冲区

ios - 下载保存在 ios 应用程序中的文件

ios - 在函数 swift 中使用 presentviewcontroller

C++ 在 Linux 和 Mac OS X 上将音频数据发送到扬声器输出

ios - 在 iOS 上使用 MTAudioProcessingTap 进行 FFT

audio - 核心音频中如何选择音频输入设备?

ios - 如何禁用 developerprofile 文件另一个 mac

ios - UICollectionView 找不到成员

java - 播放采样声音javax.sound.sampled时的巨大延迟