11

I'm trying to compile this code:

#include <stdio.h>
#include <stdlib.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;
}

When I use this command in terminal:

libtool --mode=link gcc `pkg-config --cflags --libs gstreamer-1.0` -o main main.c

I get this error:

Package gstreamer-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gstreamer-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gstreamer-1.0' found
libtool: link: gcc -o main main.c

And this error:

main.c:3:21: fatal error: gst/gst.h: No such file or directory

But I have installed GStreamer 1.0 and libtool with apt-get. Do you have any ideas where should I start? I have dig whole Internet searching the answer and no one has the answer.

dwinar
  • 113
  • 1
  • 1
  • 5

2 Answers2

10

gst/gst.h is provided by libgstreamer1.0-dev. Install it:

sudo apt-get install libgstreamer1.0-dev

In Code::Blocks, you can set custom include locations and linker flags. In the Project menu, click on Build options: enter image description here

muru
  • 193,181
  • 53
  • 473
  • 722
  • That helped a lot! But now I wonder how did you know that this is required? GStreamer Development Manual doesn't say a word about this. One more question would be what to type in "linker settings" in Codeblocks for example to allow compilation with IDE? – dwinar Oct 14 '14 at 20:28
  • 1
    @dwinar Usually in Ubuntu header files for some package (say `something`) are provided by the corresponding `dev` package (say `something-dev` or `libsomething-dev`). Unless the manual is Ubuntu specific, it will probably just say "Install the development files" or something like that (or assume you compiled from source). – muru Oct 14 '14 at 20:33
  • Thank you very much. I'll remember this in the future. I have solved my IDE issue also :) Yes I knew where to find project settings but I didn't know what to write there but now I found it. I had add compiler option: "`pkg-config --cflags gstreamer-1.0`" and in linker settings `pkg-config --libs gstreamer-1.0` – dwinar Oct 14 '14 at 21:12
  • @dwinar my update was a bit too late then. Was I correct? – muru Oct 14 '14 at 21:13
  • Almost but that doesn't matter :P you saved me with your "sudo apt-get install libgstreamer1.0-dev" advice. Thanks again! – dwinar Oct 14 '14 at 21:18
  • I have the same issue, yet although I have installed (sudo apt-get install libgstreamer1.0-dev), and have the files in /usr/include/gstreamer-1.0, I still get the same error. – ransh Apr 05 '17 at 15:38
4

For people using Eclipse you should do the followings to make the project from within Eclipse:

Right click the project name and select properties. Under C/C++ Build, select Settings.

  1. Under Tool Settings, open GCC C complier and select miscellaneous. Add the following to other flags text box:

    `pkg-config --cflags gstreamer-1.0` -fPIC
    
  2. Under Tool Settings, open GCC C++ Linker and select miscellaneous. Add the following to linker flags text box:

    `pkg-config --libs gstreamer-1.0 gobject-2.0 glib-2.0`
    
  3. Under Tool Settings, open GCC C++ Linker and select Libraries. Add gstreamer-1.0, gobject-2.0 and glib-2.0 under Libraries section.

Your application should compile and link successfully then.

mehdi
  • 41
  • 3