如何使用v4l2 linux界面从网络摄像头获取视频?

时间:2018-03-09 20:54:03

标签: c linux ioctl v4l2 v4l

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

TM_SELECTED_TEXT

源代码头文件:

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

2 个答案:

答案 0 :(得分:1)

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

gcc v4l2grab.c -lv4l1 -lv4l2

答案 1 :(得分:0)

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

sudo apt-get install -y libv4l-dev

顺便说一句,以上链接无效,新链接为here