GNOME Bugzilla – Bug 597867
Plugins good do not build on Ubuntu Hardy (kernel 2.6.24)
Last modified: 2009-10-09 09:35:45 UTC
Created attachment 145091 [details] [review] fix If you try to build plugins good 0.10.16 on Hardy, it will fail with a cryptic error like this: make[4]: Entering directory `/tmp/buildd/gst-plugins-good0.10-0.10.16/sys/v4l2' CC gstv4l2.o CC gstv4l2colorbalance.o CC gstv4l2object.o gstv4l2object.c: In function 'gst_v4l2_object_fill_format_list': gstv4l2object.c:842: warning: implicit declaration of function '_IOWR' gstv4l2object.c:842: error: expected expression before 'struct' gstv4l2object.c: In function 'gst_v4l2_object_probe_caps_for_format_and_size': gstv4l2object.c:1304: error: expected expression before 'struct' gstv4l2object.c:1331: error: expected expression before 'struct' gstv4l2object.c: In function 'gst_v4l2_object_probe_caps_for_format': gstv4l2object.c:1519: error: expected expression before 'struct' gstv4l2object.c:1540: error: expected expression before 'struct' gstv4l2object.c: In function 'gst_v4l2_object_get_nearest_size': gstv4l2object.c:1737: error: expected expression before 'struct' gstv4l2object.c:1744: error: expected expression before 'struct' gstv4l2object.c:1764: error: expected expression before 'struct' gstv4l2object.c:1771: error: expected expression before 'struct' gstv4l2object.c: In function 'gst_v4l2_object_set_format': gstv4l2object.c:1804: error: expected expression before 'struct' gstv4l2object.c:1816: error: expected expression before 'struct' gstv4l2object.c:1827: error: expected expression before 'struct' gstv4l2object.c: In function 'gst_v4l2_object_start_streaming': gstv4l2object.c:1882: warning: implicit declaration of function '_IOW' gstv4l2object.c:1882: error: expected expression before 'int' gstv4l2object.c: In function 'gst_v4l2_object_stop_streaming': gstv4l2object.c:1895: error: expected expression before 'int' make[4]: *** [libgstvideo4linux2_la-gstv4l2object.lo] Error 1 It's because _IOWRT is defined in ioctl.h. Doing #include <sys/ioctl.h> fixes the issue. This does not happen with newer kernels (2.6.28 and newer do not suffer from this, I don't know what exact version of the kernel fixed this). The attached patch (include_ioctl.patch) fixes the issue for me, although is not probably the optimal solution (I'm #including for all operating systems, in all cases).
Yes, there needs to be a configure check too... I'll do that later, thanks.
Actually this looks more like a problem with your headers... _IOWR and _IOW are not used anywhere in the v4l2 plugin sources. The first line that fails because _IOWR is not found is: > if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_ENUM_FMT, format) < 0) { Apart from that, sys/ioctl.h is already included via v4l2_calls.h and only not included if libv4l is used. So you are using libv4l and their headers don't include everything they need.
> Actually this looks more like a problem with your headers... _IOWR and _IOW are > not used anywhere in the v4l2 plugin sources. > The first line that fails because _IOWR is not found is: >> if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_ENUM_FMT, format) < 0) { There is no problem with my headers. _IOWR and _IOW are used in the v4l2 plugin because the v4l2 plugin includes videodev2.h. VIDIOC_ENUM_FMT is defined in videodev2.h as: /usr/include/linux/videodev2.h:#define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) And no, sys/ioctl.h is not already included via v4l2_calls.h, and my patch should be a proof of that: unless I explictly #include <sys/ioctl.h>, compilation fails. This is probably due to wrong detection of libv4l2: #ifdef HAVE_LIBV4L2 # include <libv4l2.h> #else # include <sys/ioctl.h> # include <linux/videodev.h> # include <linux/videodev2.h> # define v4l2_fd_open(fd, flags) (fd) # define v4l2_close close # define v4l2_dup dup # define v4l2_ioctl ioctl # define v4l2_read read # define v4l2_mmap mmap # define v4l2_munmap munmap #endif You can easily check this by installing Ubuntu Hardy, then updating the GStreamer stuff from my PPA ( http://launchpad.net/~pgquiles/+archive/ppa ). The plugins good package there already includes the patch. That patch is not needed in Ubuntu Jaunty, so there is some kind of trouble with old kernels.
commit f10435580f571177b0c8825320983fc9b9423202 Author: Pau Garcia i Quiles <pgquiles@elpauer.org> Date: Fri Oct 9 11:34:16 2009 +0200 v4l2: Include sys/ioctl.h for the V4L ioctl requests Old videodevice2.h kernel headers used ioctl stuff without including ioctl.h, making compilation fail on older systems. Note: Including ioctl.h here is only a workaround for old kernel headers, should be removed once everybody has new enough headers. Fixes bug #597867.