简体   繁体   English

GStreamer Qt WINDOWS

[英]GStreamer Qt WINDOWS

There is lot's of information about configuring .pro file for Qt in linux to run GStreamer. 关于在Linux中为Qt配置.pro文件以运行GStreamer的信息很多。 But it looks so difficult to do the same in WINDOWS. 但是在WINDOWS中做同样的事情看起来是如此困难。 I downloaded Gst from their official site and ran an installer. 我从他们的官方网站下载了Gst并运行了安装程序。 Now it's in D:\\gstreamer\\1.0\\x86 ... I found the only description from someone who tried to change qt .pro file. 现在它在D:\\ gstreamer \\ 1.0 \\ x86 ...中,我找到了唯一尝试更改qt .pro文件的人的描述。 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 并且项目find会在为gstreamer键入“ gst_init(”和其他内容时提供帮助,但会产生错误

undefined reference to gst_init 未定义对gst_init的引用

Here is the question. 这是问题。 How to connect GStreamer in windows? 如何在Windows中连接GStreamer?

#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. C:/Qt/Qt5.1.1/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug mingw32-make [1]:输入目录'D:/ Projects / AllTests / Qt / build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug' g ++ -Wl,-子系统,控制台-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:在函数main': D:\\Projects\\AllTests\\Qt\\build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug/../Console/main.cpp:8: undefined reference to gst_init的main': D:\\Projects\\AllTests\\Qt\\build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug/../Console/main.cpp:8: undefined reference to collect2.exe:错误:ld返回1个退出状态Makefile.Debug:77:目标'debug \\ Console.exe'的配方失败mingw32-make [1]: * [debug \\ Console.exe]错误1 mingw32-make [1]:离开目录'D:/ Projects / AllTests / Qt / build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug'makefile:34:目标'debug'的配方失败mingw32-make:* [debug]错误2 00:20:18:进程«C:\\ Qt \\ Qt5.1.1 \\ Tools \\ mingw48_32 \\ bin \\ mingw32-make.exe»以代码2结尾。

You have to specify the gstreamer libraries against which your binaries must be linked. 您必须指定二进制文件必须链接到的gstreamer库。

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. 根据有关qmake的文档 ,通过发出LIBS += -Lc:/gstreamer/1.0/x86/lib您正在指示qmake在给定路径内查找库,但实际上没有哪个库链接到您的二进制文件。 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 . 我对gstreamer并不熟悉,因此我不确定在您介绍的特定情况下必须链接哪些库,但是我想您会在gstreamer/1.0/x86/lib找到它们。 If unsure you could add them all to the list prepending the lower case "l" to their names. 如果不确定,可以将它们全部添加到列表中,并在其名称前加上小写字母“ l”。 For instance, if the library were called math , you'd add it by appending -lmath to the list. 例如,如果该库名为math ,则可以通过将-lmath附加到列表中来添加它。 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. 除了像上面建议的那样手动指定应该链接到二进制文件的库之外,您还可以选择使用pkg-config为您完成艰苦的工作。 This documentation for gstreamer states it suficies to add the following to the .pro file: 有关gstreamer的文档,指出可以将以下内容添加到.pro文件中:

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. 这种方法的缺点自然是必须首先获取pkg-config才能在系统上运行。

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 . 我发现在Windows上,您确实可以避免pkg-config的东西,而不需要将gstreamer所需的所有内容都包含为libs和.h But also you will need to include GTK . 但是,您还需要包括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). Kei Naga的一个很好的答案在VS 2010中提供了qt的想法http://gstreamer-devel.966125.n4.nabble.com/Configure-Visual-Studio-2010-for-GStreamer-td3804989.html,但如果您转移了所有内容他写了.pro文件,它也将起作用(至少对我而言)。

Here is the code of pro file: 这是pro文件的代码:

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. 它使用由GStreamer安装设置的环境变量-因此应在其他PC上工作。 There is a different environment variable for 64 bit, but same principle. 64位环境变量不同,但原理相同。

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). 此外,您需要确保C:\\ gstreamer \\ 1.0 \\ x86 \\ bin在路径上(控制面板,也可以在QtCreator中进行设置)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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