Error while compiling PortAudio examples

守給你的承諾、 提交于 2019-12-05 16:04:48

Assuming you are compiling using gcc and you have a single C file foo.c, the compiler command would be

gcc -o foo foo.c -lrt -lasound -ljack -lpthread -lportaudio

The -l parameters are there to link the required libraries to your program, e.g. -lrt will link librt.a. The order does matter.

I got the required libraries from here: http://www.portaudio.com/docs/v19-doxydocs/compile_linux.html#comp_linux3. Don't know if they are correct. At least you need -lportaudio, obviously.

If the libraries are not found, you have to provide gcc a path, e.g.

gcc -L/usr/lib -o foo foo.c -lrt -lasound -ljack -lpthread -lportaudio

Regarding the header, you don't actually need to copy it into your program's directory. You'd rather include it as

#include <portaudio.h>

and add its directory to the include search path:

gcc -I/usr/include -L/usr/lib -o foo foo.c -lrt -lasound -ljack -lpthread -lportaudio

Of course, all this is better done in a Makefile.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!