1

我正在尝试从 v4l2 API运行示例代码。当我尝试运行示例代码时,我在编译程序本身时遇到了问题。请检查错误,在编译步骤中我需要安装或标记要传递的东西吗?

ubox:~/capVideoFrame$ gcc v4l2grab.c && ./a.out
/tmp/cc0E2uRM.o: In function `xioctl':
v4l2grab.c:(.text+0x2b): undefined reference to `v4l2_ioctl'
/tmp/cc0E2uRM.o: In function `main':
v4l2grab.c:(.text+0xf3): undefined reference to `v4l2_open'
v4l2grab.c:(.text+0x30f): undefined reference to `v4l2_mmap'
v4l2grab.c:(.text+0x6a2): undefined reference to `v4l2_munmap'
v4l2grab.c:(.text+0x6c4): undefined reference to `v4l2_close'
collect2: error: ld returned 1 exit status

源代码头文件:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <linux/videodev2.h>
#include "/usr/include/libv4l2.h" // I am using ubuntu, so pointing to this location
4

2 回答 2

2

要成功编译,您需要为其添加标志-lv4l1 -lv4l2

gcc v4l2grab.c -lv4l1 -lv4l2
于 2018-03-09T21:23:13.013 回答
0

如果您之前没有安装 libv4l2,则需要先安装它:

sudo apt-get install -y libv4l-dev

顺便说一句,上面的链接已经死了,新链接在这里

于 2020-11-01T10:43:42.287 回答