Building Application Lib

HT ht.techdev at gmail.com
Wed Jan 31 22:22:52 UTC 2018


Hi

Trying to build a gstreamer application as a library, e.g., a call to a 
function within the library would create the loop, pipeline, bus, etc. I 
am generating the .so as follows:

  gcc -shared -Wl,-soname,$@  `pkg-config --cflags --libs gstreamer-1.0` 
-D_GNU_SOURCE -I . -g -O2 -Wall  -fPIC libtst.c -o libtst.so'

where libtst.c looks like:

#include <glib.h>
#include <glib/gprintf.h>
#include <gst/gst.h>
#include <arpa/inet.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <gst/check/gstcheck.h>
#include <sys/syscall.h>


void create(int argc,char* argv[]){

     GstElement *pipeline;
     GstBus *bus;
     GMainLoop *loop;
     guint bus_watch_id;
     GError *err = NULL;

   gst_init(&argc, &argv);
     pipeline = gst_parse_launch (argv, &err);
     if (!pipeline) {
         g_print ("Parse error: %s\n", err->message);
         exit (1);
     }

     loop = g_main_loop_new (NULL, FALSE);

     bus = gst_element_get_bus (pipeline);

...

}


The test program looks like:

#include "libtst.h"

void main(int argc,char* argv[) {
     create(argc,argv);
}

And is built as:

gcc test.c -L. -ltst -I. -o test -Wl,--allow-shlib-undefined `pkg-config 
--cflags gstreamer-1.0`


After setting LD_LIBRARY_PATH to point gstreamer.so, glib.so, ... on the 
target machine, I see the following:

*** ./test: symbol lookup error: /root/libtst.so: undefined symbol: gst_init
Aborted

Doing ldd on the library file does not show any of gst, or glib related 
libraries, e.g:

ldd libtst.so
         linux-vdso.so.1 (0x00007ffea7559000)
         libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x00007f33b220e000)
         libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f33b1e62000)
         /lib64/ld-linux-x86-64.so.2 (0x000055d77ec76000)


I am not creating this .so correctly, Any thoughts, as how to go about it?

Cheers,



More information about the gstreamer-devel mailing list