Linking against external libraries in gstreamer plugin using autotools
Asked Answered
E

1

4

I have written a gstreamer plugin using the boilerplate template refrenced in the gstreamer plugin writers guide (http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-building-boiler.html). I first built the plugin without full implementation of the chain function (basically an empty plugin that passed data from the source to sink with no changes).

I am now implementing the chain function to perform a basic filtering on the data in the buffer. The filtering uses an external sharpening library (which I have successfully used outside of gstreamer). When building using autotools I get no errors, but when creating a pipeline using the new plugin, I get an undefined symbol error

(gst-plugin-scanner:6512): GStreamer-WARNING **: Failed to load plugin '/usr/local/lib/gstreamer-1.0/libgstsharpening.so': /usr/local/lib/gstreamer-1.0/libgstsharpening.so: undefined symbol: InitializeSharpeningModule

I am admittedly very new to autotools, and I believe my problem lies somewhere in that process, but I can't figure out where. The external sharpening library being used can be found here

/public/gstreamer_pipeline/lib/libsharpening.so

I edited the plugin Makefile.am found in the src directory for my plugin

/public/gstreamer_pipeline/src/gst-sharpening/src

The contents of the edited Makefile.am are

plugin_LTLIBRARIES = libgstsharpening.la

libgstsharpening_la_SOURCES = gstsharpening.c gstsharpening.h

libgstsharpening_la_CFLAGS = $(GST_CFLAGS) -I/public/gstreamer_pipeline/include
libgstsharpening_la_LIBADD = $(GST_LIBS) -lsharpening
libgstsharpening_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -L/public/gstreamer_pipeline/lib
libgstsharpening_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)

noinst_HEADERS = gstsharpening.h

The undefined symbol error is occuring in the case of creating the pipeline from a main program, or creating the pipeline from the command line using

gst-launch-1.0 fakesrc ! sharpening ! fakesink

The output of running ldd on the new created plugin library (without modifying LD_LIBRARY_PATH) is

ldd /usr/local/lib/gstreamer-1.0/libgstsharpening.so
    linux-vdso.so.1 =>  (0x00007fff17bc0000)
    libgstbase-1.0.so.0 => /usr/local/lib/libgstbase-1.0.so.0 (0x00007f3c51778000)
    libgstcontroller-1.0.so.0 => /usr/local/lib/libgstcontroller-1.0.so.0 (0x00007f3c51568000)
    libgstreamer-1.0.so.0 => /usr/local/lib/libgstreamer-1.0.so.0 (0x00007f3c51250000)
    libgmodule-2.0.so.0 => /usr/local/lib/libgmodule-2.0.so.0 (0x00007f3c5104d000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f3c50db0000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f3c50bac000)
    libgobject-2.0.so.0 => /usr/local/lib/libgobject-2.0.so.0 (0x00007f3c5095f000)
    libffi.so.6 => /usr/local/lib/../lib64/libffi.so.6 (0x00007f3c50755000)
    libglib-2.0.so.0 => /usr/local/lib/libglib-2.0.so.0 (0x00007f3c50420000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3c50203000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f3c4fffa000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f3c4fc67000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003406c00000)

The configure.log output http://pastie.org/10450341

The output of make and make install http://pastie.org/10450352

Erland answered 28/9, 2015 at 14:47 Comment(4)
so where is the symbol InitializeSharpeningModule used? and where it is defined (exporter)?Dyadic
It is used in the chain() function of the new plugin I am trying to build, and is defined in /public/gstreamer_pipeline/lib/libsharpening.soErland
do you have LD_LIBRARY_PATH (or some other means) setup to make the runtime linker look in /public/gstreamer_pipeline/lib/ for libraries?Dyadic
I have LD_LIBRARY_PATH properly set for runtime linking, yes.Erland
F
2

Most likely the runtime linker/loader cannot find the auxiliary libraries (libsharpening.so) in the non-standard paths (/public/gstreamer_pipeline/lib/).

(You tell automake where to look for that library for the linking step in the build-process; this does not mean that the runtime linker will look at the same place).

There are various ways to fix that:

  • install the library in a place where the runtime linker will look for it, e.g. /usr/local/lib/ (that's the good way)

    • configure the runtime linker to permanently look for libraries in your non-standard paths, by adding it to /etc/ld.so.config (or - if your sytem supports it - by adding it to the new file /etc/ld.so.conf.d/gstreamer_pipeline.conf)
  • tell the runtime linker to use an additional path for library resolving, via the LD_LIBRARY_PATH environmental variable.

e.g.

LD_LIBRARY_PATH=/public/gstreamer_pipeline/lib/ gst-launch-1.0 \
          fakesrc ! sharpening ! fakesink
Fillender answered 29/9, 2015 at 13:50 Comment(3)
I have LD_LIBRARY_PATH pointing to the non-standard library location. When I run ldd on the plugin shared object that I build, it does not even show the library /public/gstreamer_pipeline/lib/libsharpening.so as being linked.Erland
please add the output of ldd libgstsharpening.so (without any LD_LIBRARY_PATH) to your question. it would also help if you could post a logfile of the build to some pastieDyadic
The question had been updated, thank you for the suggestions.Erland

© 2022 - 2024 — McMap. All rights reserved.