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.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
Niroshan
  • 2,064
  • 6
  • 35
  • 60
  • 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. – Niroshan Jun 05 '11 at 12:37
  • 2
    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.h – Mirkules Aug 31 '11 at 22:38
  • 1
    I just wanted to clarify, it is Niroshan's comment on Alberto's answer that fixes the issue for VXL. – diedthreetimes Nov 21 '11 at 20:15

5 Answers5

98

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).

bukzor
  • 37,539
  • 11
  • 77
  • 111
  • 4
    This worked for me for Pygame, which will not install from pip on Ubuntu 12.10 without this. – kitti Feb 07 '13 at 23:14
  • 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: http://askubuntu.com/questions/203630/easy-install-pygame-not-working-due-to-linux-videodev-h-no-such-file-or-direct – nucleartide Feb 20 '13 at 23:23
  • also outlines in http://stackoverflow.com/questions/15694753/which-library-needed-to-satisfy-include-linux-videodev-h – isync Aug 13 '15 at 15:24
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 
jsbueno
  • 99,910
  • 10
  • 151
  • 209
Alberto
  • 744
  • 5
  • 2
  • 9
    need to edit cap_v4l.cpp, replace #include with #include as suggested in the link provided by karlphillip – Niroshan May 05 '11 at 17:17
  • 7
    or better yet, just create a symlink to the file named videodev.h. No patching needed. – Tamás Szelei Jun 16 '12 at 07:19
  • 1
    For those googling "linux/videodev.h": I fixed a different software (http://stackoverflow.com/a/10641571/778990) by linking videodev.h to videodev2.h. – ignis Sep 29 '12 at 05:54
  • How to symlink videodev.h? Well, refer to bukzor's answer below for that. – isync Aug 13 '15 at 15:26
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.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • 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 you – Niroshan May 02 '11 at 14:44
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.

Kevin
  • 4,618
  • 3
  • 38
  • 61
sujit
  • 31
  • 1
0

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

Vyacheslav
  • 26,359
  • 19
  • 112
  • 194