0

使用简单的应用程序编译 rt 音频时遇到问题

#include "RtAudio.h"

int main()
{
        RtAudio *audio = 0;
        audio = new RtAudio;
        delete audio;
return 0;
}

编译

g++ -Wall -D__MACOSX_CORE__ -o probe rtaudio.cpp RtAudio.cpp -framework CoreAudio -lpthread 

错误

Undefined symbols for architecture x86_64:
  "RtAudio::RtAudio(RtAudio::Api)", referenced from:
      _main in rtaudio-e456a2.o
      _main in RtAudio-a64f56.o
"RtAudio::~RtAudio()", referenced from:
  _main in rtaudio-e456a2.o
  _main in RtAudio-a64f56.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

1 回答 1

0

您需要将您的代码与 RtAudio 库链接,因此添加-lrtAudio到您的编译命令:

g++ -Wall -D__MACOSX_CORE__ -o probe RtAudio.cpp -framework CoreAudio -lpthread -lrtAudio

你已经包含了两个 RtAudio,一个“rtaudio.cpp”和两个 RtAudio.cpp,你应该清除 rtaudio.cpp,因为你#include "RtAudio.h"在你的 main 中包含了大写

于 2017-01-23T16:09:02.097 回答