Rob Dickson
Rob Dickson

Reputation: 61

Official V4L2 Driver for raspberry pi, how do I add lrt flags to a makefile?

I am creating a small python application that uses v4l on the raspberry pi. After hours of troubleshooting I'm close to installing it. I just need to compile the Official V4L2 Driver.

I'm following this tutorial https://www.ics.com/blog/raspberry-pi-camera-module#.VAaCHqM0_YQ

When I get to the make step I get this error: undefined reference to symbol 'clock_gettime'

A Google search tells me that I need to "Add -lrt to the list of libraries you link to", or put it in the makefile. I don't know anything about make and configure. I tried to read a little but I am doing this for work and don't have time to take a course. I don't know what to do... Please help...

I should also mention that I just dont know do I change makefile or makefile.in or configure? I tried to place "-lrt" in makefile but it is complicated and confusing to figure out where to put it.

Here is the actual error:

Making all in v4l2-compliance
make[3]: Entering directory '/home/pi/v4l-utils/utils/v4l2-compliance'
  CXXLD  v4l2-compliance
/usr/bin/ld: v4l2-test-buffers.o: undefined reference to symbol 'clock_gettime@@
GLIBC_2.4'
//lib/arm-linux-gnueabihf/librt.so.1: error adding symbols: DSO missing from com
mand line
collect2: ld returned 1 exit status
Makefile:388: recipe for target 'v4l2-compliance' failed
make[3]: *** [v4l2-compliance] Error 1
make[3]: Leaving directory '/home/pi/v4l-utils/utils/v4l2-compliance'
Makefile:347: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/pi/v4l-utils/utils'
Makefile:386: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/pi/v4l-utils'
Makefile:315: recipe for target 'all' failed
make: *** [all] Error 2

I tried to edit Makefile and found a that read "LIBS=" and I changed it to "LIBS=-lrt", This didn't work.

I found line 388 in the Makefile this is what it reads in that area:

# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
#     (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
    @fail= failcom='exit 1'; \
    for f in x $$MAKEFLAGS; do \
      case $$f in \
        *=* | --[!k]*);; \
        *k*) failcom='fail=yes';; \
      esac; \
    done; \
    dot_seen=no; \
    target=`echo $@ | sed s/-recursive//`; \
    list='$(SUBDIRS)'; for subdir in $$list; do \
      echo "Making $$target in $$subdir"; \
      if test "$$subdir" = "."; then \
        dot_seen=yes; \
        local_target="$$target-am"; \
      else \
        local_target="$$target"; \
      fi; \
      ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
      || eval $$failcom; \
    done; \
    if test "$$dot_seen" = "no"; then \
      $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
    fi; test -z "$$fail"

So I tried to run make like this: make CFLAGS='-lrt', That didn't do anything. I looked at config.status and this is another confusing file.

Upvotes: 4

Views: 5977

Answers (2)

Rob Dickson
Rob Dickson

Reputation: 61

Well I paid a consultant and he told me to change two different files.

First file:
/v4l-utils/utils/v4l2-compliance/Makefile

Second file:
/v4l-utils/utils/v4l2-ctl/Makefile

Change the line with "LDFLAGS =" to "LDFLAGS = -lrt"

After that V4l2 compiled just fine on Raspberry Pi.

Upvotes: 2

Deri
Deri

Reputation: 21

This works too:-

LDFLAGS=-lrt ./configure
make

Upvotes: 2

Related Questions