2

I am trying to compile the Gstreamer SDK tutorial 1: Hello World application with C++

I have run into quite a few problems but after getting all my includes files in place I am still having issues with it.

The highest supported distro of Ubuntu is "Ubuntu Raring Ringtail (13.04)" for the Gstreamer SDK so I installed it using those repositories for x64

I am running Ubuntu 14.04 x64 and the package seemed to install ok.

Here is what I have for code (adapted to C++):

#include <stdio.h>
#include <gst/gst.h>

//using namespace std;

int main(int argc, char *argv[])
{
  GstElement *pipeline;
  GstBus *bus;
  GstMessage *msg;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /* Build the pipeline */
  pipeline = gst_parse_launch("playbin2 uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);

  /* Start playing */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* Wait until error or EOS */
  bus = gst_element_get_bus (pipeline);
  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, (GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS));

  /* Free resources */
  if (msg != NULL)
    gst_message_unref (msg);
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}

And here is the error I am getting along with my g++ invoke:

11:46:28 **** Build of configuration Debug for project gst-test ****
make all 
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/include/libxml2 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -O0 -g3 -Wall -c -fmessage-length=0  `pkg-config  --cflags --libs gstreamer-0.10` -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Finished building: ../main.cpp

Building target: gst-test
Invoking: GCC C++ Linker
g++  -o "gst-test"  ./main.o   
./main.o: In function `gst_message_unref':
/usr/include/gstreamer-0.10/gst/gstmessage.h:347: undefined reference to `gst_mini_object_unref'
./main.o: In function `main':
/home/kyle/workspace/gst-test/Debug/../main.cpp:19: undefined reference to `gst_init'
/home/kyle/workspace/gst-test/Debug/../main.cpp:22: undefined reference to `gst_parse_launch'
/home/kyle/workspace/gst-test/Debug/../main.cpp:25: undefined reference to `gst_element_set_state'
/home/kyle/workspace/gst-test/Debug/../main.cpp:28: undefined reference to `gst_element_get_bus'
/home/kyle/workspace/gst-test/Debug/../main.cpp:29: undefined reference to `gst_bus_timed_pop_filtered'
/home/kyle/workspace/gst-test/Debug/../main.cpp:34: undefined reference to `gst_object_unref'
/home/kyle/workspace/gst-test/Debug/../main.cpp:35: undefined reference to `gst_element_set_state'
/home/kyle/workspace/gst-test/Debug/../main.cpp:36: undefined reference to `gst_object_unref'
collect2: error: ld returned 1 exit status
make: *** [gst-test] Error 1

And here is my pkg-config output:

pkg-config --cflags --libs gstreamer-0.10
-pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2  -pthread -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lxml2 -lglib-2.0 

I have tried a bunch of things but the closest I could find to my problem was this:

Issues linking against gstreamer libraries ubuntu 11.10

and this: http://lists.freedesktop.org/archives/gstreamer-devel/2009-May/022575.html

Thanks for the help, and I apologize if it is something stupid I am still new to C++

Community
  • 1
  • 1
Mel0n
  • 85
  • 1
  • 2
  • 12
  • 1
    The problem is that you have the libraries before the object files when building. Try to split the `pkg-config` command into two parts, one for the compiler flags (`--cflags`) and one for the libraries and linker flags (`--libs`).Edit the makefile to put the linker libraries *after* the object files when linking. – Some programmer dude Feb 19 '15 at 17:03
  • Thanks, I had already tried that. I just removed my own includes from the front and it looks like this now, still getting the error 'make all Building file: ../main.cpp Invoking: GCC C++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length=0 `pkg-config --cflags gstreamer-0.10` `pkg-config --libs gstreamer-0.10` -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" Finished building: ../main.cpp' – Mel0n Feb 19 '15 at 17:07
  • 3
    Put the `pkg-config --libs gstreamer-0.10` command *last*, and when *linking* not compiling. – Some programmer dude Feb 19 '15 at 17:09

0 Answers0