linux/videodev.h : no such file or directory - OpenCV on ubuntu 11.04
Asked Answered
D

5

69

I tried to install OpenCV2.2 on Ubuntu 11.04. But OpenCV compilation fails stating an error related to linux/videodev.h file. File available in /user/includes/linux is named videodev2.h.

/home/user/OpenCV-2.2.0/modules/highgui/src/cap_v4l.cpp:217:28: fatal error:    linux/videodev.h: No such file or directory
compilation terminated.
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_v4l.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2

Is there a solution for this ?

thank you.

Deflation answered 30/4, 2011 at 14:1 Comment(3)
updated version is available at https://code.ros.org/svn/opencv/trunk. And libv4l-dev is need to be installed in addition to other libraries.Deflation
This error also occurs when compiling VXL. Alberto's answer, coupled with Niroshan's comment helped me solve it. You must make Niroshan's changes to these two files: $VXLSRC/contrib/oul/oufgl/frame_grabber_v4l.h and $VXLSRC/contrib/oul/oufgl/frame_grabber_vil.hLancewood
I just wanted to clarify, it is Niroshan's comment on Alberto's answer that fixes the issue for VXL.Shortly
S
72
sudo apt-get install libv4l-dev

Editing for RH based systems :

On a Fedora 16 to install pygame 1.9.1 (in a virtualenv):

sudo yum install libv4l-devel
sudo ln -s /usr/include/libv4l1-videodev.h   /usr/include/linux/videodev.h 
Spillway answered 5/5, 2011 at 13:49 Comment(4)
need to edit cap_v4l.cpp, replace #include <videodev.h> with #include <libv4l1-videodev.h> as suggested in the link provided by karlphillipDeflation
or better yet, just create a symlink to the file named videodev.h. No patching needed.Unhopedfor
For those googling "linux/videodev.h": I fixed a different software (https://mcmap.net/q/281632/-v4l2-very-simple-example-closed) by linking videodev.h to videodev2.h.Lunch
How to symlink videodev.h? Well, refer to bukzor's answer below for that.Preraphaelite
M
99

The current answer is incomplete. Installing libv4l-dev creates a /usr/include/linux/videodev2.h but doesn't solve the stated problem of not being able to find linux/videodev.h. The library does ship header files for compatibility, but fails to put them where applications will look for them.

sudo apt-get install libv4l-dev
cd /usr/include/linux
sudo ln -s ../libv4l1-videodev.h videodev.h

This provides a linux/videodev.h, and of the right version (1).

Mulford answered 25/12, 2012 at 0:54 Comment(3)
This worked for me for Pygame, which will not install from pip on Ubuntu 12.10 without this.Lloyd
I'm installing Pygame as well and this also worked for me. If you're installing Pygame via pip (and not via apt), remember to also install pygame's dependencies: askubuntu.com/questions/203630/…Downe
also outlines in #15695253Preraphaelite
S
72
sudo apt-get install libv4l-dev

Editing for RH based systems :

On a Fedora 16 to install pygame 1.9.1 (in a virtualenv):

sudo yum install libv4l-devel
sudo ln -s /usr/include/libv4l1-videodev.h   /usr/include/linux/videodev.h 
Spillway answered 5/5, 2011 at 13:49 Comment(4)
need to edit cap_v4l.cpp, replace #include <videodev.h> with #include <libv4l1-videodev.h> as suggested in the link provided by karlphillipDeflation
or better yet, just create a symlink to the file named videodev.h. No patching needed.Unhopedfor
For those googling "linux/videodev.h": I fixed a different software (https://mcmap.net/q/281632/-v4l2-very-simple-example-closed) by linking videodev.h to videodev2.h.Lunch
How to symlink videodev.h? Well, refer to bukzor's answer below for that.Preraphaelite
A
3

v4l support has been dropped in recent kernel versions (including the one shipped with Ubuntu 11.04).

EDIT: Your question is connected to a recent message that was sent to the OpenCV users group, which has instructions to compile OpenCV 2.2 in Ubuntu 11.04. Your approach is not ideal.

Athanasia answered 30/4, 2011 at 19:52 Comment(1)
I have few questions, that link tells to download libcv-dev libcvaux-dev libhighgui-dev and libcv2.1 libcvaux2.1 libhighgui2.1 libraries. Don't they belong to two earlier versions of OpenCV? And later it tells to download OpenCV2.2 source code. Is this accurate? please explain me, I am not that familiar with OCV library. Thank youDeflation
C
3

The patch is here: https://code.ros.org/trac/opencv/attachment/ticket/862/OpenCV-2.2-nov4l1.patch

By adding #ifdef HAVE_CAMV4L around

#include <linux/videodev.h>

in OpenCV-2.2.0/modules/highgui/src/cap_v4l.cpp and removing || defined (HAVE_CAMV4L2) from line 174 allowed me to compile.

Charmine answered 12/5, 2011 at 14:51 Comment(0)
A
0

for CMake remove/disable with_libv4l with_v4l variables if you do not need this lib.

Abdullah answered 1/11, 2016 at 19:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.