【嵌入式】---交叉编译 移植 ALSA 报错 error: ‘__kernel_long_t’ undeclared (first use in this function)

本文详细记录了在编译ALSA库时遇到的关于__kernel_long_t未声明的错误,并提供了具体的解决方案,涉及修改timer_local.h文件,添加__kernel_long_t类型定义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、报错Log

In file included from ../../include/sound/asound.h:1:0,
                 from ../../include/local.h:146,
                 from timer_local.h:22,
                 from timer_hw.c:22:
timer_hw.c: In function ‘snd_timer_hw_open’:
../../include/alsa/sound/uapi/asound.h:882:42: error: ‘__kernel_long_t’ undeclared (first use in this function)
 #define SNDRV_TIMER_IOCTL_TREAD ((sizeof(__kernel_long_t) >= sizeof(time_t)) ? \
                                          ^
timer_hw.c:249:17: note: in expansion of macro ‘SNDRV_TIMER_IOCTL_TREAD’
   if (ioctl(fd, SNDRV_TIMER_IOCTL_TREAD, &arg) < 0) {
                 ^
../../include/alsa/sound/uapi/asound.h:882:42: note: each undeclared identifier is reported only once for each function it appears in
 #define SNDRV_TIMER_IOCTL_TREAD ((sizeof(__kernel_long_t) >= sizeof(time_t)) ? \
                                          ^
timer_hw.c:249:17: note: in expansion of macro ‘SNDRV_TIMER_IOCTL_TREAD’
   if (ioctl(fd, SNDRV_TIMER_IOCTL_TREAD, &arg) < 0) {
                 ^
Makefile:381: recipe for target 'timer_hw.lo' failed
make[3]: *** [timer_hw.lo] Error 1
make[3]: *** 正在等待未完成的任务....
make[3]: Leaving directory '/home/icedustpan/buildroot-2020.05.1/output/build/alsa-lib-1.2.2/src/timer'
Makefile:541: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/icedustpan/buildroot-2020.05.1/output/build/alsa-lib-1.2.2/src'
Makefile:404: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/icedustpan/buildroot-2020.05.1/output/build/alsa-lib-1.2.2'
package/pkg-generic.mk:266: recipe for target '/home/icedustpan/buildroot-2020.05.1/output/build/alsa-lib-1.2.2/.stamp_built' failed
make: *** [/home/icedustpan/buildroot-2020.05.1/output/build/alsa-lib-1.2.2/.stamp_built] Error 2

2、解决方法

在这个文件 timer_local.h

alsa-lib-1.2.2/src/timer/timer_local.h

sudo vim ./output/build/alsa-lib-1.2.2/src/timer/timer_local.h

添加以下内容

#ifndef __kernel_long_t
typedef long        __kernel_long_t;
typedef unsigned long    __kernel_ulong_t;
#endif

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秋知叶i

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值