简体   繁体   English

GStreamer:在C ++中与GST_OBJECT斗争

[英]GStreamer: Struggling with GST_OBJECT in C++

I have started to take a look into GStreamer 1.0 in the last days. 最近几天,我开始研究GStreamer 1.0。 The first examples worked fine but now I am at a point where I need GST_OBJECT(obj) . 第一个示例运行良好,但现在我需要GST_OBJECT(obj)
When I try to compile the example using it, the compiler outputs undefined reference to symbol 'g_type_check_instance_cast' . 当我尝试使用该示例编译该示例时,编译器将outputs undefined reference to symbol 'g_type_check_instance_cast' I am using Eclipse Luna for compiling. 我正在使用Eclipse Luna进行编译。 My OS is Ubuntu 14.04, as a compiler I use GCC. 我的操作系统是Ubuntu 14.04,作为编译器,我使用GCC。 In Eclipse I have added 在Eclipse中,我添加了
/usr/lib/x86_64-linux-gnu/glib-2.0/include
/usr/include/gstreamer-1.0
/usr/include/glib-2.0
to the include paths of the C++ Compiler and 到C ++编译器的包含路径,并
glib-2.0
gstnet-1.0
gstbase-1.0
gstcheck-1.0
gstreamer-1.0
gstcontroller-1.0
to the GCC C++ Linker libraries. 到GCC C ++链接器库。 I am new to adding external libraries to C++ so I have no idea while the compiler fails. 我是向C ++添加外部库的新手,所以在编译器失败时我一无所知。

Short code snippet I have used: 我使用过的简短代码段:
#include <iostream>
#include <gst/gst.h>

using namespace std;

int main(int argc, char **argv) { GstElement *myFirstElement; int main(int argc, char **argv) { GstElement * myFirstElement;

gst_init(&argc, &argv);

myFirstElement = gst_element_factory_make("fakesrc", "source");

if(!myFirstElement)
    return -1;

gst_object_unref(GST_OBJECT(myFirstElement));

return 0;

}` }`

Well, if I compile 好吧,如果我编译

#include <iostream>
#include <gst/gst.h>

using namespace std;

int main(int argc, char **argv)
{
  GstElement *myFirstElement;

  gst_init(&argc, &argv);

  myFirstElement = gst_element_factory_make("fakesrc", "source");

  if(!myFirstElement)
      return -1;

  gst_object_unref(GST_OBJECT(myFirstElement));

  return 0;
}

using 使用

g++ -o main main.cc  `pkg-config --cflags --libs gstreamer-1.0`

everything works fine. 一切正常。 Might be a problem with your setup... 您的设置可能有问题...

Your issue might be the linking order of the libraries. 您的问题可能是库的链接顺序。 When linking libraries, the order actually matter. 链接库时,顺序实际上很重要。 For example, if libA requires symbol from libB, then you need to link in the order of -lA -lB. 例如,如果libA需要libB中的符号,则需要按-lA -lB的顺序链接。 If you reverse the order then the linking would fail. 如果您颠倒顺序,则链接将失败。

My guess is that if you linked glib before gstreamer then it would fail, as gstreamer depends on symbols from glib. 我的猜测是,如果您在gstreamer之前链接glib,则它将失败,因为gstreamer依赖于glib中的符号。

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

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