简体   繁体   English

RT音频Mac错误G ++编译错误

[英]RT audio Mac error g++ compiling error

Having problems getting rt audio to compile using simple application 使用简单的应用程序获取rt音频进行编译时遇到问题

#include "RtAudio.h"

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

to compile 编译

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

error 错误

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)

You need to link your code with RtAudio library, so add -lrtAudio to your compile command: 您需要将代码与RtAudio库链接,因此将-lrtAudio添加到编译命令中:

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

And you have included two RtAudio, one "rtaudio.cpp" and two RtAudio.cpp, you should clear rtaudio.cpp, because you included #include "RtAudio.h" with uppercase in your main 并且您已经包含了两个RtAudio,一个“ rtaudio.cpp”和两个RtAudio.cpp,您应该清除rtaudio.cpp,因为您在主目录中包含了#include "RtAudio.h"并带有大写字母

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM