You are not logged in.

#1 2009-05-18 15:11:27

rdmelin
Member
From: Ellensburg, WA, USA
Registered: 2007-08-27
Posts: 45

Linking error when compiling patched version

I should understand this stuff better by now sad

I'm trying to build a patched version of zoneminder includung the libv4l libraries to better support web cams. In zm_local_camera.cpp I've added

#include <libv4l2.h>
#include <libv4l1.h>

and replaced all the ioctl() open() close() mmap() etc statements with the v4l2_ioctl()v4l2_ open() v4l2_close() v4l2_mmap() etc versions.

The first stage of compiling goes without error, but then linking (relinking?) stage it bails with this error

collect: relinking
zm_local_camera.o: In function `vidioctl(int, int, void*)':
zm_local_camera.cpp:(.text+0x2ff): undefined reference to `v4l2_ioctl'
zm_local_camera.o: In function `LocalCamera::PostCapture()':
zm_local_camera.cpp:(.text+0x4b8): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x50b): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x547): undefined reference to `v4l2_ioctl'
zm_local_camera.o: In function `LocalCamera::Contrast(int)':
zm_local_camera.cpp:(.text+0x9f2): undefined reference to `v4l2_ioctl'
zm_local_camera.o:zm_local_camera.cpp:(.text+0xa1b): more undefined references to `v4l2_ioctl' follow
zm_local_camera.o: In function `LocalCamera::GetCurrentSettings(char const*, char*, int, bool)':
zm_local_camera.cpp:(.text+0x1d21): undefined reference to `v4l1_open'
zm_local_camera.cpp:(.text+0x1d89): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x20a4): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x218d): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x257b): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x26ad): undefined reference to `v4l1_close'
zm_local_camera.o: In function `LocalCamera::Terminate()':
zm_local_camera.cpp:(.text+0x3e6f): undefined reference to `v4l1_close'
zm_local_camera.cpp:(.text+0x3e9f): undefined reference to `v4l1_munmap'
zm_local_camera.cpp:(.text+0x3f37): undefined reference to `v4l2_munmap'
zm_local_camera.o: In function `LocalCamera::Initialise()':
zm_local_camera.cpp:(.text+0x4182): undefined reference to `v4l1_open'
zm_local_camera.cpp:(.text+0x4775): undefined reference to `v4l2_mmap'
zm_local_camera.cpp:(.text+0x49b9): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x4a46): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x4a89): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x4ad8): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x4b0a): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x4b9d): undefined reference to `v4l1_mmap'
zm_local_camera.cpp:(.text+0x560a): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x564d): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x5671): undefined reference to `v4l2_ioctl'
zm_local_camera.cpp:(.text+0x56a3): undefined reference to `v4l2_ioctl'
zm_local_camera.o: In function `LocalCamera::PrimeCapture()':
zm_local_camera.cpp:(.text+0x6018): undefined reference to `v4l2_ioctl'
collect2: ld returned 1 exit status
make[2]: *** [zmc] Error 1

Can someone tell me what I am missing. I will do my homework if someone can just give me a hint. smile

Offline

#2 2009-05-18 16:52:49

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 698
Website

Re: Linking error when compiling patched version

Hi

add to ld -lv4l1 -lv4l2 as appropriate wink

Offline

#3 2009-05-18 23:27:54

rdmelin
Member
From: Ellensburg, WA, USA
Registered: 2007-08-27
Posts: 45

Re: Linking error when compiling patched version

Thank you very much, it works. Specifically I added these to the LIBS= line in Makefile.

And now my zoneminder system works with my cheap gspca supported webcam, which it didn't before smile

Offline

#4 2009-10-22 19:04:57

ben123
Member
Registered: 2009-04-19
Posts: 13

Re: Linking error when compiling patched version

The above suggestion worked the last time I built zoneminder, but when I tried upgrading today, with kernel 2.6.31 and the same exact zoneminder release (1.24.2), I'm getting the same error again.  As you can see, -lv4l1 and -lv4l2 are in the g++ command.  This is using the latest gcc package, 4.4.1, and I think the last build might have been on 4.4.0.  I've also upgraded x264 and ffmpeg to svn latest in the last couple of days, but I doubt that should have anything to do with is.  Can somebody help?  Thanks.

make  all-recursive
make[1]: Entering directory `/home/ben/abs/zoneminder/src/ZoneMinder-1.24.2'
Making all in src
make[2]: Entering directory `/home/ben/abs/zoneminder/src/ZoneMinder-1.24.2/src'
g++ -frepo -march=x86-64 -mtune=generic -O2 -pipe  -L/usr/lib -L/usr/lib/mysql -Wl,--hash-style=gnu -Wl,--as-needed -lv4l1 -lv4l2 -o zmc  zmc.o zm_box.o zm_buffer.o zm_camera.o zm_comms.o zm_config.o zm_coord.o zm.o zm_db.o zm_debug.o zm_event.o zm_exception.o zm_file_camera.o zm_ffmpeg_camera.o zm_image.o zm_jpeg.o zm_local_camera.o zm_monitor.o zm_ffmpeg.o zm_mpeg.o zm_poly.o zm_regexp.o zm_remote_camera.o zm_remote_camera_http.o zm_remote_camera_rtsp.o zm_rtp.o zm_rtp_ctrl.o zm_rtp_data.o zm_rtp_source.o zm_rtsp.o zm_sdp.o zm_signal.ozm_stream.o zm_thread.o zm_time.o zm_timer.o zm_user.o zm_utils.o zm_zone.o  -lz -lbz2 -lswscale -lavformat -lavcodec -lavutil -lpcre -lcrypto -ldl -lpthread -ljpeg -lmysqlclient
zm_local_camera.o: In function `vidioctl(int, int, void*)':
zm_local_camera.cpp:(.text+0x28f): undefined reference to `v4l2_ioctl'
zm_local_camera.o: In function `LocalCamera::PostCapture()':
zm_local_camera.cpp:(.text+0x454): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x4a5): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x4de): undefined reference to `v4l1_ioctl'
zm_local_camera.o: In function `LocalCamera::Contrast(int)':
zm_local_camera.cpp:(.text+0x86b): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x891): undefined reference to `v4l1_ioctl'
zm_local_camera.o:zm_local_camera.cpp:(.text+0xa6b): more undefined references to `v4l1_ioctl' follow
zm_local_camera.o: In function `LocalCamera::GetCurrentSettings(char const*, char*, int, bool)':
zm_local_camera.cpp:(.text+0x1866): undefined reference to `v4l1_open'
zm_local_camera.cpp:(.text+0x18c8): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x1bbb): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x1c93): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x205a): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x2159): undefined reference to `v4l1_close'
zm_local_camera.o: In function `LocalCamera::Terminate()':
zm_local_camera.cpp:(.text+0x367d): undefined reference to `v4l1_close'
zm_local_camera.cpp:(.text+0x36ac): undefined reference to `v4l1_munmap'
zm_local_camera.cpp:(.text+0x3755): undefined reference to `v4l2_munmap'
zm_local_camera.o: In function `LocalCamera::Initialise()':
zm_local_camera.cpp:(.text+0x3939): undefined reference to `v4l1_open'
zm_local_camera.cpp:(.text+0x3eaa): undefined reference to `v4l2_mmap'
zm_local_camera.cpp:(.text+0x409d): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x413d): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x41ab): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x4207): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x4233): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x42aa): undefined reference to `v4l1_mmap'
zm_local_camera.cpp:(.text+0x45e7): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x4633): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x4650): undefined reference to `v4l1_ioctl'
zm_local_camera.cpp:(.text+0x467c): undefined reference to `v4l1_ioctl'
zm_local_camera.o: In function `LocalCamera::PrimeCapture()':
zm_local_camera.cpp:(.text+0x5320): undefined reference to `v4l1_ioctl'
collect2: ld returned 1 exit status
make[2]: *** [zmc] Error 1
make[2]: Leaving directory `/home/ben/abs/zoneminder/src/ZoneMinder-1.24.2/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ben/abs/zoneminder/src/ZoneMinder-1.24.2'
make: *** [all] Error 2

Offline

#5 2009-10-22 19:16:08

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,937
Website

Re: Linking error when compiling patched version

add before configure:

export LDFLAGS="${LDFLAGS//-Wl,--as-needed}"

Last edited by wonder (2009-10-22 19:16:32)


Give what you have. To someone, it may be better than you dare to think.
Blog

Offline

#6 2009-10-22 20:12:00

ben123
Member
Registered: 2009-04-19
Posts: 13

Re: Linking error when compiling patched version

Thank you very much.  I added the following to PKGBUILD just before configure and it worked perfectly.

  LDFLAGS="-lv4l1 -lv4l2 ${LDFLAGS}"

I had this previously on the configure command line:

    --with-extralibs="-lv4l1 -lv4l2" \

The zm configure script ended up adding it to the very end of the LDFLAGS list, which was the cause of the problem as was pointed out.  By the way, did makepkg change recently with "-Wl,--as-needed" added to LDFLAGS by default or did gcc break?  I had a similar problem with mplayer in which I had to unset LDFLAGS before compile.

Offline

#7 2009-10-22 20:20:58

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,937
Website

Re: Linking error when compiling patched version

the new LDFLAGS that was added in makepkg.conf can break some applications


Give what you have. To someone, it may be better than you dare to think.
Blog

Offline

#8 2009-12-02 22:56:13

spychodelics
Member
Registered: 2009-06-08
Posts: 22

Re: Linking error when compiling patched version

yeah its running fine thx

Offline

Board footer

Powered by FluxBB