How does GStreamer load static plugins?

Nikos Chantziaras realnc at gmail.com
Tue Jun 4 18:21:36 PDT 2013


On 03/06/13 00:28, Sebastian Dröge wrote:
> On So, 2013-06-02 at 13:58 +0300, Nikos Chantziaras wrote:
>> I'm not able to find any documentation on this.  How would I use
>> GStreamer in an application that has GStreamer itself as well the
>> plugins linked-in statically?  And for that matter, how would I link it
>> correctly?  Are the pkg-config files enough, or should I instead
>> manually link-in every plugin?
>
> You need to manually link in every single plugin that is going to be
> used by your application and manually register it with
> GST_PLUGIN_STATIC_DECLARE() and GST_PLUGIN_STATIC_REGISTER().

I've been battling with this for quite a while now.  I've successfully 
built gstreamer 0.10 from the SDK source repo, so I've now got those 
macros.  I used the "--enable-static-plugins" option when building.

But no matter what I do, I get "undefined reference" linker errors. 
Even for this very simple test C program (main.c):

   #include <gst/gstplugin.h>

   GST_PLUGIN_STATIC_DECLARE(coreelements);

   int main(void)
   {
           GST_PLUGIN_STATIC_REGISTER(coreelements);
           return 0;
   }

I tried compiling with:

   gcc `pkg-config gstreamer-0.10 --cflags` main.c \
     `pkg-config gstreamer-0.10 --libs` \
     `pkg-config gstreamer-plugins-base-0.10 --libs`

That fails, so I'm trying to manually link against "libgstcoreelements.a":

   gcc `pkg-config gstreamer-0.10 --cflags` main.c \
     `pkg-config gstreamer-0.10 --libs` \
     `pkg-config gstreamer-plugins-base-0.10 --libs` \
     -L/prefix/usr/lib/gstreamer-0.10 -lgstcoreelements

And even that produces the same "undefined reference" error.  So now I'm 
trying to include all static plugins with brute-force, by including all 
static archives in the build:

   gcc `pkg-config gstreamer-0.10 --cflags` main.c \
     `pkg-config gstreamer-0.10 --libs` \
     `pkg-config gstreamer-plugins-base-0.10 --libs` \
     /prefix/usr/lib/gstreamer-0.10/*.a

But again, same error message.  I don't know what else to do.  Any help 
would be greatly appreciated.


More information about the gstreamer-devel mailing list