undefined reference to `shm_open'

Rob Landley rob at landley.net
Thu Dec 17 06:03:56 UTC 2009


On Tuesday 15 December 2009 12:20:14 Niko Lau wrote:
> 2009/12/15 Ian Harrold <ian.harrold at gmail.com>:
> > On Tue, Dec 15, 2009 at 10:31 AM, Niko Lau
> > <niko84embedded at googlemail.com>
> >
> > wrote:
> >> 2009/12/15 Lennart Sorensen <lsorense at csclub.uwaterloo.ca>:
> >> > On Tue, Dec 15, 2009 at 05:16:05PM +0100, Niko Lau wrote:
> >> >> I want to use the libv4l2 for my arm platform with uclibc cross
> >> >> compiler.
> >> >> When I link a appl with that lib I get the following error:
> >> >> arm-linux-uclibc-gcc -Wall -O2 -g -I../libv4l2/include
> >> >> -L../libv4l2/lib  -o capture capture.c -lv4l2 -lv4lconvert
> >> >> ../libv4l2/lib/libv4lconvert.so: undefined reference to `shm_open'
> >> >> collect2: ld returned 1 exit status
> >> >> make: *** [test] Fehler 1
> >> >>
> >> >> The lib is built with the same compiler without any error.
> >> >> Can someone give me a hint what the problem is. Since it works with a
> >> >> glibc compiler i think the problem is the uclibc.
> >> >
> >> > The man page (for the glibc version) says you have to link with -lrt.
> >> > I don't see you doing that.  Do you have to?  Does uclibc have such
> >> > a thing and does it do shm_open?  I guess it must or the header files
> >> > would have failed yoiur earlier compile already.
> >> >
> >> > --
> >> > Len Sorensen
> >>
> >> The -lrt flag is set during libv4lconvert building. I can see shm_open
> >> in the include file (/sys/mman.h)
> >> so i think uclibc has shm_open.
> >>
> >> Niko
> >
> > Did you compile uclibc with "UCLIBC_HAS_REALTIME" option for real time
> > support?  I beleive this to be correct.
> >
> > shm_open() implementation is in /librt/shm.c  and defined in
> > /include/sys/shm.h
> >
> > So if your code capture.c uses shm, then you need to link the
> > implementation -lrt in the compile to fix the linker error.   If that
> > still doesn't work then perhaps you didn't compile uclibc to support shm?
>
> Ok it looks like shm is not fully implemented yet.
>
> -lrt in compile line doesnt work. UCLIBC_HAS_REALTIME is on, but there
> is no /librt/shm.c.
>
> Thanks for the help.
> Niko

My Firmware Linux project is using this patch to add shm support to 0.9.30.1:

http://impactlinux.com/hg/hgwebdir.cgi/firmware/raw-file/6fb534830d8f/sources/patches/uClibc-add-
shm.patch

If you're unfamiliar with uClibc development, it can be a bit surprising
to see how long it takes the developers to realize somebody might actually
be using a release version.  (I think they forget that they actually have
releases, or that people other than uCllibc developers use it...)

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds


More information about the uClibc mailing list