简体   繁体   中英

GStreamer Qt WINDOWS

There is lot's of information about configuring .pro file for Qt in linux to run GStreamer. But it looks so difficult to do the same in WINDOWS. I downloaded Gst from their official site and ran an installer. Now it's in D:\\gstreamer\\1.0\\x86 ... I found the only description from someone who tried to change qt .pro file. I did the same:

INCLUDEPATH += c:/gstreamer/1.0/x86/include \
        c:/gstreamer/1.0/x86/include/gstreamer-1.0/gst \
        c:/gstreamer/1.0/x86/include/glib-2.0\
        c:/gstreamer/1.0/x86/include/glib-2.0/glib \
        c:/gstreamer/1.0/x86/lib/glib-2.0/include

LIBS += -Lc:/gstreamer/1.0/x86/lib

CONFIG += c:/gstreamer/1.0/x86/lib/pkgconfig

And the project find , gives assistance when typing "gst_init(" and other stuff for gstreamer but it gives an error

undefined reference to gst_init

Here is the question. How to connect GStreamer in windows?

#include <QCoreApplication>
#include <gst/gst.h>
int main(int argc, char *argv[])
{

    gst_init(NULL,NULL);
    //g_print("abc");

    return 0;
}

C:/Qt/Qt5.1.1/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'D:/Projects/AllTests/Qt/build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug' g++ -Wl,-subsystem,console -mthreads -o debug\\Console.exe debug/main.o -Lc:/gstreamer/1.0/x86/lib -LC:\\Qt\\Qt5.1.1\\5.1.1\\mingw48_32\\lib -lQt5Cored debug/main.o: In function main': D:\\Projects\\AllTests\\Qt\\build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug/../Console/main.cpp:8: undefined reference to gst_init' collect2.exe: error: ld returned 1 exit status Makefile.Debug:77: recipe for target 'debug\\Console.exe' failed mingw32-make[1]: * [debug\\Console.exe] Error 1 mingw32-make[1]: Leaving directory 'D:/Projects/AllTests/Qt/build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug' makefile:34: recipe for target 'debug' failed mingw32-make: * [debug] Error 2 00:20:18: Process «C:\\Qt\\Qt5.1.1\\Tools\\mingw48_32\\bin\\mingw32-make.exe» finishes with code 2.

You have to specify the gstreamer libraries against which your binaries must be linked.

According to this documentation for qmake , by issuing LIBS += -Lc:/gstreamer/1.0/x86/lib you are instructing qmake to look for libraries within the given path, but not which of them to actually link to your binaries. I am not familiar with gstreamer, so I'm not sure what libraries must be linked in the specific case you presented, but I guess you'll find them all in gstreamer/1.0/x86/lib . If unsure you could add them all to the list prepending the lower case "l" to their names. For instance, if the library were called math , you'd add it by appending -lmath to the list. Just be cautious not to add multiple versions of the same library, say a debug version and a release version, at the same time, or you most certainly will get multiple reference linking errors.

Instead of manually specifying the libraries which should be linked to your binaries as suggested above, you also have the option to use pkg-config to do the hard work for you. This documentation for gstreamer states it suficies to add the following to the .pro file:

CONFIG += link_pkgconfig
PKGCONFIG += QtGStreamer-0.10

The drawback to this approach is naturally that you have to get pkg-config to work on your system first.

I found that on windows you really can avoid pkg-config stuff bit than need to include everything is needed for gstreamer as libs and .h . But also you will need to include GTK . A good answer by Kei Naga provides the idea for qt in VS 2010 http://gstreamer-devel.966125.n4.nabble.com/Configure-Visual-Studio-2010-for-GStreamer-td3804989.html but if you transfer everything he wrote to .pro file it will also work (at least for me).

Here is the code of pro file:

INCLUDEPATH += C:/ ... /GStreamer/v0.10.6/sdk/include/gstreamer-0.10 \
           C:/ ... /GTK/include/libxml2 \
           C:/ ... /GTK/include/libglade-2.0 \
                    C:/ ... /GTK/lib/gtkglext-1.0/include \
                    C:/ ... /GTK/lib/glib-2.0/include \
                    C:/ ... /GTK/lib/gtk-2.0/include \
                    C:/ ... /GTK/include/gtkglext-1.0 \
                    C:/ ... /GTK/include/atk-1.0 \
                    C:/ ... /GTK/include/cairo \
                    C:/ ... /GTK/include/pango-1.0 \
                    C:/ ... /GTK/include/glib-2.0 \
                    C:/ ... /GTK/include/gtk-2.0 \
                    C:/ ... /GTK/include

LIBS += -LC:/ ... /GTK/lib -LC:/ ... /GStreamer/v0.10.6/sdk/lib -lgstreamer-0.10 -lglib-2.0  -lgobject-2.0 -lgtk-win32-2.0 -lgstinterfaces-0.10

I find this works for me. It uses the environment variable set by the GStreamer install - so should work on other PCs. There is a different environment variable for 64 bit, but same principle.

QT       += core gui
TARGET = GStreamerTest4
TEMPLATE = app
SOURCES += \
    qt-videooverlay.cpp

HEADERS  +=
FORMS    +=

GstreamerDir=$$(GSTREAMER_1_0_ROOT_X86)

INCLUDEPATH = $${GstreamerDir}/include/gstreamer-1.0
INCLUDEPATH += $${GstreamerDir}/include/glib-2.0
INCLUDEPATH += $${GstreamerDir}/lib/glib-2.0/include
INCLUDEPATH += $${GstreamerDir}/lib/gstreamer-1.0/include

LIBS = $${GstreamerDir}/lib/gstreamer-1.0.lib
LIBS += $${GstreamerDir}/lib/*.lib

In addition, you need to make sure C:\\gstreamer\\1.0\\x86\\bin is on the path (control panel or you can set it in QtCreator).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM