0

Хотел посмотреть как работают библиотеки Gstremer в QtCreator. Хотел запустить примеры с сайта, но столкнулся с проблемой..

- Как правильно подключить библиотеки?

У меня выдает ошибки:

  • LNK2019 unresolved external symbol g_clear_error referenced in function main

Так же подобные для: g_free, g_clear, g_print и тд.

  • LNK1120 6 unresolved externals (что логично, у меня 6 ошибок :) )

Читал подобные вопросы и вроде даже разобрался с хитростями подключения, но ответ на этот вопрос не нашел.

ДЕТАЛИ:

QtCreator с компилятором Desktop Qt5.15.2 MSVC 2019 64-bit;

Gstreamer 1.18.1 (с сайта скачал: gstreamer-1.0-msvc-x86_64-1.18.1 и gstreamer-1.0-devel-msvc-x86_64-1.18.1), взял с одной рабочей open-source проги.

PRO file:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

INCLUDEPATH += "F:\gstreamer\1.0\msvc_x86_64\lib\glib-2.0\include" INCLUDEPATH += "F:\gstreamer\1.0\msvc_x86_64\include\gstreamer-1.0" INCLUDEPATH += "F:\gstreamer\1.0\msvc_x86_64\include\glib-2.0"

LIBS += "F:/gstreamer/1.0/msvc_x86_64/lib/gstreamer-1.0.lib"

SOURCES +=
main.cpp
mainwindow.cpp

HEADERS +=
mainwindow.h

FORMS +=
mainwindow.ui

Default rules for deployment.

qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target

Main.cpp:

#include "mainwindow.h"
#include <gst/gst.h>

#include <QApplication>

int main(int argc, char *argv[]) {

GstElement *pipeline, *source, *sink;
GstBus *bus;
GstMessage *msg;
GstStateChangeReturn ret;

/* Initialize GStreamer */
gst_init (&amp;argc, &amp;argv);

/* Create the elements */
source = gst_element_factory_make (&quot;videotestsrc&quot;, &quot;source&quot;);
sink = gst_element_factory_make (&quot;autovideosink&quot;, &quot;sink&quot;);

/* Create the empty pipeline */
pipeline = gst_pipeline_new (&quot;test-pipeline&quot;);

if (!pipeline || !source || !sink) {
  g_printerr (&quot;Not all elements could be created.\n&quot;);
  return -1;
}

/* Build the pipeline */
gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
if (gst_element_link (source, sink) != TRUE) {
  g_printerr (&quot;Elements could not be linked.\n&quot;);
  gst_object_unref (pipeline);
  return -1;
}

/* Modify the source's properties */
g_object_set (source, &quot;pattern&quot;, 0, NULL);

/* Start playing */
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
  g_printerr (&quot;Unable to set the pipeline to the playing state.\n&quot;);
  gst_object_unref (pipeline);
  return -1;
}

/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg =
    gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
    (GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS));

/* Parse message */
if (msg != NULL) {
  GError *err;
  gchar *debug_info;

  switch (GST_MESSAGE_TYPE (msg)) {
    case GST_MESSAGE_ERROR:
      gst_message_parse_error (msg, &amp;err, &amp;debug_info);
      g_printerr (&quot;Error received from element %s: %s\n&quot;,
          GST_OBJECT_NAME (msg-&gt;src), err-&gt;message);
      g_printerr (&quot;Debugging information: %s\n&quot;,
          debug_info ? debug_info : &quot;none&quot;);
      g_clear_error (&amp;err);
      g_free (debug_info);
      break;
    case GST_MESSAGE_EOS:
      g_print (&quot;End-Of-Stream reached.\n&quot;);
      break;
    default:
      /* We should not reach here because we only asked for ERRORs and EOS */
      g_printerr (&quot;Unexpected message received.\n&quot;);
      break;
  }
  gst_message_unref (msg);
}

/* Free resources */
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);

}

evo
  • 498
  • 1
  • 3
  • 14

0 Answers0