简体   繁体   English

缺少 v4l2、linux 与 uapi/linux 中的包含

[英]missing include from v4l2, linux vs uapi/linux

I'm learning the v4l2 API for configuring video devices through v4l2-ctl.我正在学习用于通过 v4l2-ctl 配置视频设备的 v4l2 API。 The code samples from ages ago are really out of date and some of the defines don't work anymore.很久以前的代码示例确实过时了,一些定义不再起作用。 There is a new method of requesting everything for the API from the kerhel which is shown in v4l2-utils.有一种新方法可以从 kerhel 请求 API 的所有内容,如 v4l2-utils 所示。 I'm trying to incorporate some of the code from v4l2-utils into my code.我正在尝试将 v4l2-utils 中的一些代码合并到我的代码中。 However, I'm getting an error from the compiler:但是,我从编译器中收到错误消息:

camera.hpp:1038:8: error: 'struct v4l2_ext_controls' has no member named 'which'

ctrls.which = V4L2_CTRL_ID2WHICH(qctrl.id); ctrls.which = V4L2_CTRL_ID2WHICH(qctrl.id);

And:和:

camera.hpp:1038:43: error: 'V4L2_CTRL_ID2WHICH' was not declared in this scope

ctrls.which = V4L2_CTRL_ID2WHICH(qctrl.id); ctrls.which = V4L2_CTRL_ID2WHICH(qctrl.id);

The field and define are in a file located in the linux source tree: /usr/src/linux-4.6.3-gentoo/include/uapi/linux/videodev2.h, but that file is not included when I specify:该字段和定义位于 linux 源代码树中的一个文件中:/usr/src/linux-4.6.3-gentoo/include/uapi/linux/videodev2.h,但是当我指定时不包括该文件:

#include <linux/videodev2.h>

What is the voodoo to get the compiler to include the correct file?让编译器包含正确文件的巫术是什么?

I've been studying the v4l2-utils source but can't figure it out.我一直在研究 v4l2-utils 源代码,但无法弄清楚。

Thanks much.非常感谢。

The file located in /usr/include was out of date.位于 /usr/include 中的文件已过期。 I had the headers installed for kernel 4.3 and needed the ones from a later version.我为内核 4.3 安装了头文件,并且需要更高版本的头文件。 The solution for my gentoo install was to add a keyword for sys-kernel/linux-headers and install the latest headers (4.7).我的 gentoo 安装的解决方案是为 sys-kernel/linux-headers 添加一个关键字并安装最新的头文件 (4.7)。

It turns out that the UAPI file becomes the headers when installed into /usr/include.事实证明,UAPI 文件在安装到 /usr/include 时成为头文件。 I could probably have accomplished this with make headers_install in my /usr/src/linux directory as well, but I'm not sure whether that is more "correct" than installing the linux-headers ebuild.我也可以使用 /usr/src/linux 目录中的 make headers_install 完成此操作,但我不确定这是否比安装 linux-headers ebuild 更“正确”。 I worry about conflicts.我担心冲突。

Hope this helps someone else...希望这对其他人有帮助...

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

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