Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues linking against gstreamer libraries ubuntu 11.10

So I am starting a project that is going to make use of the gstreamer libraries. I am running the test project from the gstreamer documentation and am getting the following error.This program worked properly on archlinux but is erroring out on ubuntu

gcc `pkg-config --cflags --libs gstreamer-0.10` main.c -o player
/tmp/cciFhGCe.o: In function `main':
main.c:(.text+0x1e): undefined reference to `gst_init'
main.c:(.text+0x36): undefined reference to `gst_version'
collect2: ld returned 1 exit status
make: *** [player] Error 1

My code is the following which I got from the gstreamer documentation

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

int
main (int   argc,
      char *argv[])
{
  const gchar *nano_str;
  guint major, minor, micro, nano;

  gst_init (&argc, &argv);

  gst_version (&major, &minor, &micro, &nano);

  if (nano == 1)
    nano_str = "(CVS)";
  else if (nano == 2)
    nano_str = "(Prerelease)";
  else
    nano_str = "";

  printf ("This program is linked against GStreamer %d.%d.%d %s\n",
          major, minor, micro, nano_str);

  return 0;
}

and the command I am using to compile is

gcc `pkg-config --cflags --libs gstreamer-0.10` main.c -o player

and the output of pkg-config

-pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/gstreamer-0.10 -I/usr/include/libxml2  -pthread -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lxml2 -lgthread-2.0 -lrt -lglib-2.0
like image 622
Mindbane Avatar asked Dec 01 '11 20:12

Mindbane


1 Answers

So thanks to the great guys on freenode #gstreamer

In unbuntu's version of gcc some changes were made to the ordering of pkg-config statements.

gcc `pkg-config gstreamer-0.10 --cflags` main.c -o player.out `pkg-config gstreamer-0.10 --libs`

Using this format fixed it.

like image 122
Mindbane Avatar answered Oct 12 '22 10:10

Mindbane