有很多关于在 linux 中为 Qt 配置 .pro 文件以运行 GStreamer 的信息。但在 WINDOWS 中做同样的事情看起来太难了。我从他们的官方网站下载了 Gst 并运行了一个安装程序。现在它在 D:\gstreamer\1.0\x86 ... 我从试图更改 qt .pro 文件的人那里找到了唯一的描述。我也是这样做的:
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
项目 find 在为 gstreamer 输入“gst_init(”和其他内容时提供帮助,但它给出了错误
undefined reference to gst_init
问题来了。如何在 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.
最佳答案
您必须指定您的二进制文件必须链接到的 gstreamer 库。
根据 this documentation for qmake ,通过发出 LIBS += -Lc:/gstreamer/1.0/x86/lib
,您指示 qmake 在给定路径中查找库,但不是将其中的哪些链接到您的二进制文件。我不熟悉 gstreamer,所以我不确定在您提供的特定情况下必须链接哪些库,但我想您会在 gstreamer/1.0/x86/lib
中找到它们。如果不确定,您可以将它们全部添加到列表中,并在它们的名称前加上小写字母“l”。例如,如果库名为 math,您可以通过将 -lmath 附加到列表中来添加它。请注意不要同时添加同一个库的多个版本,比如调试版本和发布版本,否则您很可能会遇到多个引用链接错误。
您还可以选择使用 pkg-config,而不是像上面建议的那样手动指定应该链接到您的二进制文件的库。为你做艰苦的工作。 This documentation for gstreamer声明将以下内容添加到 .pro 文件就足够了:
CONFIG += link_pkgconfig
PKGCONFIG += QtGStreamer-0.10
这种方法的缺点自然是您必须先让 pkg-config 在您的系统上运行。
关于windows - GStreamer Qt WINDOWS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20360932/