PDA

View Full Version : [SOLVED] unable compiling hello.c gstreamer program..



kcode
October 25th, 2008, 11:30 AM
I'm unable to compile this program:



#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;
}


with following error:



gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10.21) hello.c -o hello
Package gstreamer-0.10.21 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gstreamer-0.10.21.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gstreamer-0.10.21' found
hello.c:1:21: error: gst/gst.h: No such file or directory
hello.c: In function ‘main’:
hello.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
hello.c:7: error: ‘nano_str’ undeclared (first use in this function)
hello.c:7: error: (Each undeclared identifier is reported only once
hello.c:7: error: for each function it appears in.)
hello.c:8: error: ‘guint’ undeclared (first use in this function)
hello.c:8: error: expected ‘;’ before ‘major’
hello.c:10: error: ‘major’ undeclared (first use in this function)
hello.c:10: error: ‘minor’ undeclared (first use in this function)
hello.c:10: error: ‘micro’ undeclared (first use in this function)
hello.c:10: error: ‘nano’ undeclared (first use in this function)
hello.c:17: warning: incompatible implicit declaration of built-in function ‘printf’


i installed gstreamer-0.10.21 manually in my home directory.
i also did:
export PKG_CONFIG_PATH=$PKGCONFIG:$libdir/pkgconfig

link i used:
used:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-helloworld-compilerun.html

thanks

nvteighen
October 25th, 2008, 12:04 PM
Well, several things.
0. Code tags in this forums are [ code ] [ /code ] (without spaces).

1. You're using the wrong compile command. You're referring to a 'gstreamer-0.10.21' pkg-config file that simply doesn't exist. It is 'gstreamer-0.10', as the documentation correctly states.

So, the compiling command would be:


gcc hello.c -o hello -Wall `pkg-config --cflags --libs gstreamer-0.10`


Note that I'm using backticks (`) not single-quotes (')! I'm not sure whether $(pkg-config...) is the same or not, but the usual way for using pkg-config is the one I describe.

2. I've refactored your code a little bit. In C you better always initialize variables... specially pointers!! And you forgot to #include <stdio.h> (for printf()).


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

int main (int argc, char *argv[])
{
/* Always initialize stuff. You're never sure what value will the variable
* take! */

gchar *nano_str = NULL; /* No longer const otherwise you won't be able to
* modify it. */
guint major = 0;
guint minor = 0;
guint micro = 0;
guint nano = 0;

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;
}

kcode
October 25th, 2008, 12:14 PM
no success:(
1. i used gstreamer-0.10.21 as i installed this version
2. it also says guint is undeclared first use in this func.
3. tried backticks --> no success

nvteighen
October 25th, 2008, 02:00 PM
no success:(
1. i used gstreamer-0.10.21 as i installed this version
2. it also says guint is undeclared first use in this func.
3. tried backticks --> no success

Just a question, where have you installed this from? I installed the 'libgstreamer0.10-dev' package from the repos and it worked.

kcode
October 25th, 2008, 02:16 PM
thanks a lot
it worked.
I installed it manually from the package downloaded from there website.
(you made my day!)
thanks again!

hnkulkarni
October 29th, 2009, 11:55 AM
Hi ,
Thanks a lot for this post.
I worked for me too..

But when we take the program to one step further , say I have to make a Qt GUI which will
pop up a window showing the version with which this GStreamer is linked with.

Then I gain get the same errors
error: gst/gst.h No such file or directory.

Can you please tell me how can I integrate GStreamer with Qt.

Thanking you all in advance.

Zugzwang
October 29th, 2009, 12:26 PM
Can you please tell me how can I integrate GStreamer with Qt.


So first of all install the development package mentioned above. The furter steps depend on the build system you are actually using. Which one is it? QMake? Then you can add the line "PKGCONFIG += gstreamer-0.10" to your solution (".pro") file.

zahidul_haque
June 5th, 2011, 06:58 PM
Hi All,

I am new to UBUNTU. I installed Ubuntu10.10 and tried running the gstreamer example.
I wrote simple gstreamer example with C flavour only like

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

int main() {
g_print("Hello! World \n");
}

but I am getting compiler error "streamer.c:1: fatal error: gst/gst.h: No such file or directory
compilation terminated."

These header files are at

/usr/include/glib-2.0/glib.h

/usr/include/gstreamer-0.10/gst/gst.h

Does anyone has an idea how to resolve this. Thanks in advance

Regards,
Zahid