尝试使用portaudio示例,但是找不到架构x86_64"的" ld:符号。

时间:2015-02-22 02:05:18

标签: c macos audio linker portaudio

我试图在Mac OS 10.10上使用portaudio,但我在尝试编译示例程序时遇到错误。这就是我所做的:

- ./ configure&&使。没问题。

- 将示例文件" pa_devs.c",libportaudio.a和portaudio.h复制到一个名为Test1的单独目录中

试图编译它

gcc -o Test1 pa_devs.c libportaudio.a -lm

-got this error:

Undefined symbols for architecture x86_64:
  "_AudioConvertHostTimeToNanos", referenced from:
      _GetStreamTime in libportaudio.a(pa_mac_core.o)
      _AudioIOProc in libportaudio.a(pa_mac_core.o)
  "_AudioConverterDispose", referenced from:
      _CloseStream in libportaudio.a(pa_mac_core.o)
  "_AudioConverterFillBuffer", referenced from:
      _AudioIOProc in libportaudio.a(pa_mac_core.o)
  "_AudioConverterNew", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
  "_AudioConverterReset", referenced from:
      _StartStream in libportaudio.a(pa_mac_core.o)
  "_AudioConverterSetProperty", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
  "_AudioDeviceAddPropertyListener", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
      _SetupDevicePropertyListeners in libportaudio.a(pa_mac_core.o)
      _AudioDeviceSetPropertyNowAndWaitForChange in libportaudio.a(pa_mac_core_utilities.o)
  "_AudioDeviceGetProperty", referenced from:
      _PaMacCore_GetChannelName in libportaudio.a(pa_mac_core.o)
      _PaMacCore_GetBufferSizeRange in libportaudio.a(pa_mac_core.o)
      _PaMacCore_Initialize in libportaudio.a(pa_mac_core.o)
      _OpenStream in libportaudio.a(pa_mac_core.o)
      _AudioDevicePropertyActualSampleRateListenerProc in libportaudio.a(pa_mac_core.o)
      _AudioDevicePropertyGenericListenerProc in libportaudio.a(pa_mac_core.o)
      _CalculateFixedDeviceLatency in libportaudio.a(pa_mac_core.o)
      ...
  "_AudioDeviceGetPropertyInfo", referenced from:
      _PaMacCore_GetChannelName in libportaudio.a(pa_mac_core.o)
      _PaMacCore_Initialize in libportaudio.a(pa_mac_core.o)
      _GetChannelInfo in libportaudio.a(pa_mac_core.o)
      _setBestSampleRateForDevice in libportaudio.a(pa_mac_core_utilities.o)
  "_AudioDeviceRemovePropertyListener", referenced from:
      _CloseStream in libportaudio.a(pa_mac_core.o)
      _AudioDeviceSetPropertyNowAndWaitForChange in libportaudio.a(pa_mac_core_utilities.o)
  "_AudioDeviceSetProperty", referenced from:
      _AudioDeviceSetPropertyNowAndWaitForChange in libportaudio.a(pa_mac_core_utilities.o)
      _setBestFramesPerBuffer in libportaudio.a(pa_mac_core_utilities.o)
     (maybe you meant: _AudioDeviceSetPropertyNowAndWaitForChange)
  "_AudioGetCurrentHostTime", referenced from:
      _GetStreamTime in libportaudio.a(pa_mac_core.o)
      _AudioIOProc in libportaudio.a(pa_mac_core.o)
  "_AudioHardwareGetProperty", referenced from:
      _PaMacCore_Initialize in libportaudio.a(pa_mac_core.o)
  "_AudioHardwareGetPropertyInfo", referenced from:
      _PaMacCore_Initialize in libportaudio.a(pa_mac_core.o)
  "_AudioObjectSetPropertyData", referenced from:
      _PaMacCore_Initialize in libportaudio.a(pa_mac_core.o)
  "_AudioOutputUnitStart", referenced from:
      _StartStream in libportaudio.a(pa_mac_core.o)
  "_AudioOutputUnitStop", referenced from:
      _StopStream in libportaudio.a(pa_mac_core.o)
      _AudioIOProc in libportaudio.a(pa_mac_core.o)
  "_AudioStreamGetProperty", referenced from:
      _CalculateFixedDeviceLatency in libportaudio.a(pa_mac_core.o)
  "_AudioUnitAddPropertyListener", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
  "_AudioUnitGetProperty", referenced from:
      _StopStream in libportaudio.a(pa_mac_core.o)
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
      _startStopCallback in libportaudio.a(pa_mac_core.o)
  "_AudioUnitInitialize", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
  "_AudioUnitRender", referenced from:
      _AudioIOProc in libportaudio.a(pa_mac_core.o)
  "_AudioUnitReset", referenced from:
      _StopStream in libportaudio.a(pa_mac_core.o)
  "_AudioUnitSetProperty", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
  "_AudioUnitUninitialize", referenced from:
      _CloseStream in libportaudio.a(pa_mac_core.o)
  "_CFRelease", referenced from:
      _PaMacCore_GetChannelName in libportaudio.a(pa_mac_core.o)
  "_CFStringCreateWithFormat", referenced from:
      _PaMacCore_GetChannelName in libportaudio.a(pa_mac_core.o)
  "_CFStringGetCString", referenced from:
      _PaMacCore_GetChannelName in libportaudio.a(pa_mac_core.o)
  "_CFStringGetLength", referenced from:
      _PaMacCore_GetChannelName in libportaudio.a(pa_mac_core.o)
  "_CloseComponent", referenced from:
      _CloseStream in libportaudio.a(pa_mac_core.o)
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
  "_FindNextComponent", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
  "_Gestalt", referenced from:
      _PaMacCore_Initialize in libportaudio.a(pa_mac_core.o)
  "_OpenAComponent", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a(pa_mac_core.o)
  "___CFConstantStringClassReference", referenced from:
      CFString in libportaudio.a(pa_mac_core.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我得到的印象是我没有正确地链接事物。有什么建议吗?

2 个答案:

答案 0 :(得分:7)

您需要包含Apple框架:

  • CoreServices.framework
  • CoreFoundation.framework
  • AudioUnit.framework
  • AudioToolbox.framework
  • CoreAudio.framework

正如你已经做过libportaudio.a

答案 1 :(得分:1)

谢谢凯文!为了获得NetBeans用户的时间,我在Mac OS X 10.12 sierra,Netbeans 8.2上安装了portaudio(http://macappstore.org/portaudio/

  • 项目必须#include "portaudio.h"
  • 右键点击项目>特性
  • 构建与GT;链接器
  • 其他选项,添加此项:

-v /usr/local/lib/libportaudio.a -framework CoreServices -framework CoreFoundation -framework AudioUnit -framework AudioToolbox -framework CoreAudio

现在它有效。这对于像我这样的新手来说很详细。