debian 实时语音通信问题记录1

利用alsa库编写录音、放音代码及调试;

alsa_fy.c:18:27: fatal error: alsa/asoundlib.h: No such file or directory
 #include<alsa/asoundlib.h>
                           ^
compilation terminated.

没有找到asoundlib.h文件,安装库

apt-get install libasound2-dev

又出现没有找到函数问题

/tmp/cce5ofiH.o: In function `main':
alsa_fy.c:(.text+0x38): undefined reference to `snd_pcm_open'
alsa_fy.c:(.text+0x5c): undefined reference to `snd_pcm_hw_params_malloc'
alsa_fy.c:(.text+0x68): undefined reference to `snd_pcm_hw_params_any'
alsa_fy.c:(.text+0x90): undefined reference to `snd_pcm_hw_params_set_format'
alsa_fy.c:(.text+0x9e): undefined reference to `snd_pcm_hw_params_set_channels'
alsa_fy.c:(.text+0xb4): undefined reference to `snd_pcm_hw_params_set_rate_near'
alsa_fy.c:(.text+0xc2): undefined reference to `snd_pcm_hw_params_set_access'
alsa_fy.c:(.text+0xd2): undefined reference to `snd_pcm_hw_params_set_period_size_near'
alsa_fy.c:(.text+0xe6): undefined reference to `snd_pcm_hw_params_get_period_size'
alsa_fy.c:(.text+0xf2): undefined reference to `snd_pcm_hw_params'
alsa_fy.c:(.text+0x188): undefined reference to `snd_pcm_writei'
alsa_fy.c:(.text+0x190): undefined reference to `snd_pcm_hw_params_free'
alsa_fy.c:(.text+0x1a2): undefined reference to `snd_pcm_close'
collect2: error: ld returned 1 exit status

程序链接的时候,找不到链接库。在gcc的参数里面加了 -lasound 选项。
可以编译通过的写法:gcc -o main main.o -lasound
gcc中库的链接顺序是从右往左进行,所以要把最基础实现的库放在最后,这样左边的lib就可以

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值