Results 1 to 16 of 16

Thread: Including external header (gst.h)

  1. #1
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Including external header (gst.h)

    Good day fellow programmers,

    I am trying to include Gstreamer into my Qt application.
    In order to do so I need to include "gst.h".

    So far I've tried to simply add it to the main.cpp file.
    Qt Code:
    1. #include <gst/gst.h>
    To copy to clipboard, switch view to plain text mode 
    I've also tried the direct file path:
    Qt Code:
    1. #include "/usr/include/gstreamer-1.0/gst/gst.h"
    To copy to clipboard, switch view to plain text mode 

    I've also tried specifying an INCLUDEPATH in the .pro file:
    Qt Code:
    1. INCLUDEPATH += /usr/include/gstreamer-1.0/gst
    To copy to clipboard, switch view to plain text mode 
    As this didn't work I tried to be a bit more specific:
    Qt Code:
    1. unix:INCLUDEPATH += /usr/include/gstreamer-1.0/gst
    To copy to clipboard, switch view to plain text mode 

    During these tries I've been using the command in main.cpp
    Qt Code:
    1. #include <gst/gst.h>
    To copy to clipboard, switch view to plain text mode 
    but received the error all the time
    Qt Code:
    1. /home/finn/GST_Test2/main.cpp:2: error: gst/gst.h: No such file or directory
    To copy to clipboard, switch view to plain text mode 
    .

    Besides that I also tried using PKGCONFIG:
    Qt Code:
    1. unix {
    2. CONFIG += link_pkgconfig
    3. PKGCONFIG += gstreamer-1.0
    4. }
    To copy to clipboard, switch view to plain text mode 

    According to this commands result gstreamer-1.0 exists on the target system.
    Qt Code:
    1. pkg-config --list-all | grep gstreamer
    To copy to clipboard, switch view to plain text mode 

    However I always receive the error
    Qt Code:
    1. :-1: error: Package gstreamer-1.0 not found
    To copy to clipboard, switch view to plain text mode 

    The target system is a Raspberry Pi running Linux Debian. I've been able to successfully build applications on that system which is why I would guess that the target system should not be the problem.

    The file gst.h does exist on the target system in the directory /usr/include/gstreamer-1.0/gst

    Does anyone has an idea how to properly include gst.h into my Qt project?
    Thanks a lot!

    Best regards,
    Plox

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Including external header (gst.h)

    INCLUDEPATH += /usr/include/gstreamer-1.0/gst
    but you try to include the header with "gst/gst.h", compiler can't find it because probably there is no "gst" subdir in "/usr/include/gstreamer-1.0/gst" directory.
    If the file path is "/usr/include/gstreamer-1.0/gst/gst.h" then you need to add "INCLUDEPATH += /usr/include/gstreamer-1.0/" and include with "gst/gst.h", or "INCLUDEPATH += /usr/include/gstreamer-1.0/gst" and include with #include <gst.h>

  3. The following user says thank you to stampede for this useful post:

    Plox (15th October 2013)

  4. #3
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Including external header (gst.h)

    Thank you for your answer, stampede.

    I modified said code lines.

    This is the .pro file:
    Qt Code:
    1. INCLUDEPATH += /usr/include/gstreamer-1.0/
    To copy to clipboard, switch view to plain text mode 

    And this is the main.cpp:
    Qt Code:
    1. #include "gst/gst.h"
    To copy to clipboard, switch view to plain text mode 

    Sadly I am still getting the error:
    Qt Code:
    1. /home/finn/GST_Test2/main.cpp:2: error: gst/gst.h: No such file or directory
    To copy to clipboard, switch view to plain text mode 

    Why does this error still occur?

    Thanks a lot!

  5. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Including external header (gst.h)

    gstreamer-1.0 exists on the target system
    By "target system" you mean the system on which you want to deploy your app, or the machine where you are trying to build the app ? I'm just confused about the term "target system".
    This file should be present on the build machine. Does it exist on your computer (the one where you are developing the app) ?

  6. The following user says thank you to stampede for this useful post:

    Plox (15th October 2013)

  7. #5
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Including external header (gst.h)

    I am developing my app on a desktop pc running Ubuntu for a Raspberry Pi running Debian.
    The file I want to include only exists on the Raspberry.

    Do I need to copy it onto the Ubuntu machine in order to use it, although it's functionality is only going to be used on the Raspberry?

  8. #6
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Including external header (gst.h)

    Yes, your compiler needs to have access to all the headers and libraries in order to build your application. Make sure to install the gstreamer package in development version.

  9. The following user says thank you to stampede for this useful post:

    Plox (15th October 2013)

  10. #7
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Including external header (gst.h)

    Allright, thanks a lot for your help, I greatly appreciate it!

    One last question: What is the difference between the regular gstreamer version and dev version?

  11. #8
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Including external header (gst.h)

    Regular version doesn't include headers required for developing applications using gstreamer, only shared libraries:
    file list for regular libgstreamer
    file list for libgstreamer-dev
    Last edited by stampede; 15th October 2013 at 15:04. Reason: updated contents

  12. The following user says thank you to stampede for this useful post:

    Plox (15th October 2013)

  13. #9
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Including external header (gst.h)

    I am afraid that I'll need help in another matter regarding this development step too.

    I've installed gstreamer on the Ubuntu machine, set the proper INCLUDEPATH and included gst.h into main.cpp.
    A look into the file system confirms that gstreamer has been successfully installed as all header files seem to be present.

    After resolving some issues regarding glib all dependencies seem to be sorted out, however I am experiencing an error as soon as I try to actually call functions from gst.h.

    This is the error I receive:
    Qt Code:
    1. undefined reference to 'gst_init'
    To copy to clipboard, switch view to plain text mode 

    As I am receiving this error for every gst.h function I reduced main.cpp to only include gst_init.
    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <gst/gst.h>
    3.  
    4. int main(int argc, char *argv[]){
    5. QCoreApplication a(argc, argv);
    6.  
    7. gst_init (NULL,NULL);
    8. return a.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 


    The file gst.h is where it's supposed to be and based on the fact that Creator even suggests "gst_init" once I type e.g "gst" into main.cpp and since the function "gst_init" is underlayed with that typical grey box I think that gst.h has been successfully included into this project.

    Why do I still receive such error messages?

    Thanks a lot for your help!

  14. #10
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Including external header (gst.h)

    "Undefined reference ..." is a linker error, you need to add library path and link to gst libraries, in .pro file:
    LIBS += -L /path/to/gstreamer/libraries
    LIBS += <gstreamer cflags>
    I dont know what are the parameters exactly, try "pkg-config --cflags --libs gstreamer-1.0" to get the values.
    btw. I think you will find some useful informations here

  15. #11
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Including external header (gst.h)

    That makes sense. This will be the first thing to be tried out tomorrow morning.

    Thank you for your help, this really made my day.

  16. #12
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Including external header (gst.h)

    It's me again..

    I run the command you suggested to get the cflags and the libs.
    This is the output:
    Qt Code:
    1. finn@ubuntu:~$ pkg-config --libs gstreamer-1.0
    2. -pthread -lgstreamer-1.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. finn@ubuntu:~$ pkg-config --cflags gstreamer-1.0
    2. -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include
    To copy to clipboard, switch view to plain text mode 

    Including the cflags into the .pro file obviously isn't a problem but I can't find any of the files listed in the -libs output, even though I searched through the entire file system.
    Searching for the listed files without "l" in front of them wasn't successfull either as I do find matching directories but no matching files.

    If I run Qt with this .pro file:
    Qt Code:
    1. (...)
    2. INCLUDEPATH += /usr/include/gstreamer-1.0/
    3. LIBS += -L -pthread -lgstreamer-1.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
    4. LIBS += -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include
    To copy to clipboard, switch view to plain text mode 

    I get the following output:
    Qt Code:
    1. :-1: error: cannot find -lgobject-2.0
    2. :-1: error: cannot find -lgmodule-2.0
    3. :-1: error: cannot find -lgthread-2.0
    4. :-1: error: cannot find -lglib-2.0
    To copy to clipboard, switch view to plain text mode 

    I am sure this is a pretty noobish question but this is the first time I am actually working with the .pro file and this is driving me nuts.

    Thank you!
    Last edited by Plox; 16th October 2013 at 11:40.

  17. #13
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Including external header (gst.h)

    For example, if you want to link to a library "/usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so", you should do:
    Qt Code:
    1. LIBS += -lgstreamer-1.0
    2. LIBS += -L/usr/lib/x86_64-linux-gnu/
    To copy to clipboard, switch view to plain text mode 
    So if you are looking for a library named "gthread-2.0" try to search for a file "libgthread-2.0.so" etc...

    There are many resources about using shared libraries, for example this one
    Try to do some research if you are not sure what those "-L , -I, -l, ..." really mean.

  18. #14
    Join Date
    Nov 2006
    Location
    indonesia
    Posts
    55
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Including external header (gst.h)

    Hi Plox,
    Your problem related with you dont give the right path for your "include" and "library" file.
    If you have an experienced about Makefile, I think you will not get a problem when using "pro" file.

    I am try to get gst library from here http://docs.gstreamer.com/display/Gs...lling+on+Linux
    Are you have all required gst library ? If not, try to check the above link.

    I am try your code and setting my pro file like this :
    Qt Code:
    1. QT += core
    2.  
    3. QT -= gui
    4.  
    5. TARGET = tesgst
    6. CONFIG += console
    7. CONFIG -= app_bundle
    8.  
    9. TEMPLATE = app
    10. INCLUDEPATH += /usr/include/gstreamer-0.10/ \
    11. /usr/include/glib-2.0/ \
    12. /usr/lib/x86_64-linux-gnu/glib-2.0/include/ \
    13. /usr/include/libxml2/
    14. LIBS += `pkg-config --cflags --libs gstreamer-0.10`
    15.  
    16. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 
    You only need to look at "INCLUDEPATH" and "LIBS" part (ignore the other part).
    The INCLUDEPATH maybe different with the other linux version. So, please check at your error message when compiling your program.
    That error maybe related with "you dont have" or "you dont setting the right path".
    You can use "find", "locate" or the other command to get the right path for you.

    I have success to compile your program using this setting with my Ubuntu 12.04.
    Best regards,

    Toto

  19. #15
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Including external header (gst.h)

    The integration of gst.h now works like a charm.
    Thank you so much!
    This brought me a looooog way!

    I am now able to compile and run this code.
    However I am experiencing performance issues which indicates that playbin is not using hardware acceleration althought gst-omx is installed on the RPi.

    According to this guide all I need to do is change the rank of the plugin which is doing the hw acceleration.

    However if I try to combine this ( http://docs.gstreamer.com/pages/viewpage.action?pageId=327735"] ) and this code I receive the following output:

    Qt Code:
    1. ** (GTK_Test_RPI:6770): WARNING **: Command line `dbus-launch --autolaunch=34069147acf8a24283639d4a51f267a2 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
    2.  
    3. ** (GTK_Test_RPI:6770): WARNING **: Command line `dbus-launch --autolaunch=34069147acf8a24283639d4a51f267a2 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
    4.  
    5. ** (GTK_Test_RPI:6770): WARNING **: Command line `dbus-launch --autolaunch=34069147acf8a24283639d4a51f267a2 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
    6.  
    7. ** (GTK_Test_RPI:6770): WARNING **: Command line `dbus-launch --autolaunch=34069147acf8a24283639d4a51f267a2 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
    8.  
    9. ** (GTK_Test_RPI:6770): WARNING **: Command line `dbus-launch --autolaunch=34069147acf8a24283639d4a51f267a2 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
    10. xcb_connection_has_error() returned true
    11. xcb_connection_has_error() returned true
    12. Cannot connect to server socket err = No such file or directory
    13. Cannot connect to server request channel
    14. jack server is not running or cannot be started
    15.  
    16. ** (GTK_Test_RPI:6770): WARNING **: Too old frames, bug in decoder -- please file a bug
    To copy to clipboard, switch view to plain text mode 

    This is the code I run:
    Qt Code:
    1. #include <gst/gst.h>
    2.  
    3.  
    4. static void enable_factory (const gchar *name, gboolean enable) {
    5.  
    6. g_type_init ();
    7.  
    8. GstRegistry *registry = NULL;
    9. GstElementFactory *factory = NULL;
    10.  
    11. registry = gst_registry_get ();
    12. if (!registry) return;
    13.  
    14. factory = gst_element_factory_find (name);
    15. if (!factory) return;
    16.  
    17. if (enable) {
    18. gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), GST_RANK_PRIMARY + 1);
    19. }
    20. else {
    21. gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), GST_RANK_NONE);
    22. }
    23.  
    24. gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (factory));
    25. return;
    26. }
    27.  
    28.  
    29. int main(int argc, char *argv[]) {
    30.  
    31. GstElement *pipeline;
    32. GstBus *bus;
    33. GstMessage *msg;
    34.  
    35.  
    36. enable_factory("omxmpeg2videodec", true);
    37.  
    38. /* Initialize GStreamer */
    39. gst_init (&argc, &argv);
    40.  
    41. /* Build the pipeline */
    42. pipeline = gst_parse_launch ("playbin uri=http://192.168.178.51:8001", NULL);
    43.  
    44. /* Start playing */
    45. gst_element_set_state (pipeline, GST_STATE_PLAYING);
    46.  
    47. /* Wait until error or EOS */
    48. bus = gst_element_get_bus (pipeline);
    49. msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, (GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS));
    50.  
    51. /* Free resources */
    52. if (msg != NULL)
    53. gst_message_unref (msg);
    54. gst_object_unref (bus);
    55. gst_element_set_state (pipeline, GST_STATE_NULL);
    56. gst_object_unref (pipeline);
    57. return 0;
    58. }
    To copy to clipboard, switch view to plain text mode 

    Edit:
    And this is the interesting part of the .pro file:

    Qt Code:
    1. INCLUDEPATH += /opt/rpi/sysroot/usr/include/gstreamer-1.0
    2. LIBS += -lglib-2.0 -lpthread -lgstreamer-1.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt
    3. LIBS += -L/opt/rpi/sysroot/lib/arm-linux-gnueabihf/ -L/opt/rpi/sysroot/usr/lib/arm-linux-gnueabihf/
    To copy to clipboard, switch view to plain text mode 

    The error output is exactly the same as if I would run the main function without trying to increase the decoders rank.



    Edited because of a moronic mistake.
    Last edited by Plox; 17th October 2013 at 20:22.

  20. #16
    Join Date
    Dec 2014
    Posts
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Including external header (gst.h)

    hello i had the same problem
    i am triying with gstreamer but i installed precompiled version …of this page
    https://wiki.matthiasbock.net/index....y_Pi#gstreamer
    i run some examples in the console but i need to add to qt 4 …to play misic with gstreamer
    my file.pro
    INCLUDE PATH += /usr/lib/arm-linux-gnueabiht/gstreamer-1.0
    LIBS += -L/ /usr/lib/arm-linux-gnueabiht/gstreamer-1.0
    LIBS += -lglib-2.0 -lpthread -lgstreamer-1.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt
    and in the main.cpp
    #include <gst/gst.h>
    but show this error gst/gst.h no such file or directory
    how i can writhe or use correctly this libs ????
    i need play mp3 in my raspberry in an aplicacion

Similar Threads

  1. Replies: 2
    Last Post: 4th January 2012, 14:26
  2. How to add external Header files and libraries?
    By askbapi in forum Installation and Deployment
    Replies: 6
    Last Post: 30th September 2010, 18:33
  3. Qt Creator PROBLEM INCLUDING 'QSystemInfo' HEADER FILE
    By Rakula in forum Qt Tools
    Replies: 1
    Last Post: 24th September 2010, 10:28
  4. Replies: 2
    Last Post: 28th February 2010, 08:38
  5. Replies: 1
    Last Post: 6th November 2009, 22:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.