Help with QtGStreamer undefined reference to QGST::init



  • I am having some trouble with implementing QtGStreamer with QT. I have downloaded the source code for QtGStreamer and put it in "C:/qt-gstreamer-1.2.0" I am trying to run one of the examples that was provided, the player example.

    Here is my code:

    player.pro

    TEMPLATE = app
    TARGET = player
    
    CONFIG += silent
    
    CONFIG += pkgconfig
    
    contains(QT_VERSION, ^4\\..*) {
        PKGCONFIG += QtGStreamer-1.0 QtGStreamerUi-1.0 QtGlib-2.0 QtGStreamerUtils-1.0
        QT += widgets
    }
    contains(QT_VERSION, ^5\\..*) {
        PKGCONFIG += Qt5GStreamer-1.0 Qt5GStreamerUi-1.0 Qt5Glib-2.0 Qt5GStreamerUtils-1.0 Qt5GStreamerQuick-1.0
        QT += widgets \
            enginio
    }
    
    QMAKE_CXXFLAGS += -std=c++0x
    
    DEFINES += QT_NO_KEYWORDS
    
    HEADERS += mediaapp.h player.h
    SOURCES += main.cpp mediaapp.cpp player.cpp
    
    INCLUDEPATH += C:\qt-gstreamer-1.2.0\src \
        C:\boost_1_58_0
    

    main.cpp

    #include "mediaapp.h"
    #include <QApplication>
    #include <QGst/Init>
    
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QGst::init(&argc, &argv);
    
    
    
        MediaApp media;
        media.show();
    
        if (argc == 2) {
            media.openFile(argv[1]);
        }
    
        return app.exec();
    }
    

    There are other cpp files in the example, but they are all giving the same type of error. When I try to build the project, I get the error "undefined reference to 'QGst::init'" I cannot figure out what I am doing wrong. I think there needs to be something changed in the .pro file, but I couldn't find anything telling me what to do to fix it. I am on Windows, using with mingw compiler.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Might be a silly question but: do you have pkg-config running on Windows ?



  • Yes, I do have it running, however now I am getting an error "QtCore/QtGlobal: No such file or directory, so I added the include path, "C:\Qt\Qt5.4.1\5.4\mingw491_32\include" but i am still getting the same error.


  • Lifetime Qt Champion

    Then there's something wrong with either your project or your setup. You shouldn't need to add anything to find Qt's headers



  • Do you have any ideas that could help?


  • Lifetime Qt Champion

    Recheck your pro file: do you have any line line QT = or INCLUDEPATH = ? Note the missing +



  • No, this is my code:

    # This is a qmake project file, provided as an example on how to use qmake with QtGStreamer.
    
    TEMPLATE = app
    TARGET = player
    
    # produce nice compilation output
    CONFIG += silent
    
    # Tell qmake to use pkg-config to find QtGStreamer.
    CONFIG += pkgconfig
    
    # Now tell qmake to link to QtGStreamer and also use its include path and Cflags.
    contains(QT_VERSION, ^4\\..*) {
        PKGCONFIG += QtGStreamer-1.0 QtGStreamerUi-1.0
    }
    contains(QT_VERSION, ^5\\..*) {
        PKGCONFIG += Qt5GStreamer-1.0 Qt5GStreamerUi-1.0
    }
    
    QT += core quick widgets
    CONFIG += qt console bootstrap
    
    # Recommended if you are using g++ 4.5 or later. Must be removed for other compilers.
    #QMAKE_CXXFLAGS += -std=c++0x
    
    # Recommended, to avoid possible issues with the "emit" keyword
    # You can otherwise also define QT_NO_EMIT, but notice that this is not a documented Qt macro.
    DEFINES += QT_NO_KEYWORDS
    
    # Input
    HEADERS += mediaapp.h player.h
    SOURCES += main.cpp mediaapp.cpp player.cpp
    
    INCLUDEPATH += C:\qt-gstreamer-1.2.0\src
    

    Line 3 and 4 (TEMPLATE and TARGET) made no difference when I added a '+' before the '='


  • Lifetime Qt Champion

    TEMPLATE and TARGET should be used with = . They contain only one value.

    Do you still have that error if you don't use pkgconfig ?



  • @SGaist Yes, If I take out the line for PKGCONFIG, I still get the same error


  • Lifetime Qt Champion

    Then create a default widget project and see if you can built it



  • @SGaist Hi, I built an blank widget project, and I build one of the examples from Qt, and it worked fine


  • Lifetime Qt Champion

    Then keep that one and introduce one by one the elements of your other project until it either fails to build or build successfully



  • For every element in the pro file, it does not fail if I put '#include <QGst/Init>' then I get the error 'QtCore/QtGlobal: No such file or directory' Then if I comment it back out, and run qmake, then build, I get no error. If I comment it out I get the error 'cannot find boost/config.hpp' until I run qmake again.

    I added 'C:\boost_1_58_0' to the include path, commented out '#include <QGst/Init>' ran qmake, and uncommented it, and it built with no error. Then I ran qmake again, and it game me the 'QtCore/QtGlobal' error again


  • Lifetime Qt Champion

    Ok… Then the silly question: do you have a QtGlobal file ? If so where is it ?



  • Yes, I have 5 copies, they are in
    "C:\Qt\Qt5.4.1\5.4\android_armv5\include\QtCore\QtGlobal"
    "C:\Qt\Qt5.4.1\5.4\android_armv7\include\QtCore\QtGlobal"
    "C:\Qt\Qt5.4.1\5.4\android_x86\include\QtCore\QtGlobal"
    "C:\Qt\Qt5.4.1\5.4\mingw491_32\include\QtCore\QtGlobal"
    "C:\Qt\Qt5.4.1\5.4\Src\qtbase\include\QtCore\QtGlobal"

    Should I have a different one somewhere else? I am building with Mingw


  • Lifetime Qt Champion

    Did you modify your kits ?



  • No, I even just got done uninstalling and reinstalling Qt 5.4.1 and QtCreator 3.3.2 and I just got the same QtCore error



  • I then added the pkgconfig and config then instead of '#include <QGst/Init>' I did '#include <QGst/init.h>' and I got back to the error of undefined reference to 'QGst::init


  • Lifetime Qt Champion

    Check the output of pkg-config for QtGStreamer, compare it to the build output of your application. Check the -I lines to see if something is currently modifying them in the wrong way


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.