![]() |
焦虑的骆驼 · 【强制】【黑化G】《夜莺》by狄醉山 - 哔哩哔哩· 1 年前 · |
![]() |
爱跑步的电影票 · BIBF主宾国 | ...· 1 年前 · |
![]() |
聪明伶俐的小马驹 · 朱介北-电气自动化与信息工程学院官网· 1 年前 · |
![]() |
深情的单杠 · 2022家庭存款有多少才算小康生活 - 简书· 1 年前 · |
![]() |
爱喝酒的充值卡 · 小毛绒玩偶价格_小毛绒玩偶最新报价_小毛绒玩 ...· 1 年前 · |
我正试图用
make -C ...
在我的系统(Kubuntu21.10)中构建一个旧的linux驱动程序。驱动程序正在声明
static struct timeval frame_timestamp;
如果我试着用这样的方法来建造它
make -C /lib/modules/`uname -r`/build M=`pwd` V=1 modules
我得到了
... has an incomplete type ‘struct timeval’
错误和其他相关错误。因此,我认为我必须将sys/time.h与
#include
一起包含到代码中。但在这种情况下,我得到了
fatal error: sys/time.h: No such file or directory
。我找不到解决这个问题的方法。(代码已经包含了一些内容,但没有来自sys/,它们都来自linux/和media/)
最后我得到了一个下面的
Makefile
:
obj-m := mydriver.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) M=$(PWD) V=1 modules
KDIR
解析为链接到
/usr/src/linux-headers-5.13.0-21-generic
的
/lib/modules/5.13.0-21-generic/build
。没有
sys/time.h
。
locate sys/time.h
返回:
/usr/include/i386-linux-gnu/sys/time.h
/usr/include/sys/time.h
/usr/include/x86_64-linux-gnu/sys/time.h
属于
libc6-dev
和
libc6-dev-i386:
。
dpkg -l *5.13.0-21*
给出:
ii linux-headers-5.13.0-21 5.13.0-21.21 all Header files related to Linux kernel version 5.13.0
ii linux-headers-5.13.0-21-generic 5.13.0-21.21 amd64 Linux kernel headers for version 5.13.0 on 64 bit x86 SMP
ii linux-image-5.13.0-21-generic 5.13.0-21.21 amd64 Signed kernel image generic
un linux-image-unsigned-5.13.0-21-generic <нет> <нет> (описание недоступно)
ii linux-modules-5.13.0-21-generic 5.13.0-21.21 amd64 Linux kernel extra modules for version 5.13.0 on 64 bit x86 >
ii linux-modules-extra-5.13.0-21-generic 5.13.0-21.21 amd64 Linux kernel extra modules for version 5.13.0 on 64 bit x86
我试图将
-I /usr/include/x86_64-linux-gnu/
硬编码成
make -C
--这是没有效果的。我还尝试从kernel.org下载一个普通内核:
https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.13.tar.xz
,并将其硬编码为
KDIR
--这没有帮助,也不包含
sys/time.h
。
问题是:如何强制我的模块构建过程查看
sys/time.h
?linux模块允许链接到libc吗?如果它不是内核的一部分,如何使它可用于模块构建过程?
发布于 2021-12-09 12:46:00
好的,似乎不能在内核模块中使用
sys/time.h
。我查看了
struct v4l2_buffer
在
linux/videodev2.h
中的定义,驱动程序应该使用
struct timeval
来初始化其
timestamp
字段,并在那里找到:
truct v4l2_buffer {
__u32 index;
__u32 type;
__u32 bytesused;
__u32 flags;
__u32 field;
#ifdef __KERNEL__
![]() |
焦虑的骆驼 · 【强制】【黑化G】《夜莺》by狄醉山 - 哔哩哔哩 1 年前 |
![]() |
聪明伶俐的小马驹 · 朱介北-电气自动化与信息工程学院官网 1 年前 |
![]() |
深情的单杠 · 2022家庭存款有多少才算小康生活 - 简书 1 年前 |