简体   繁体   English

链接gstreamer库ubuntu 11.10的问题

[英]Issues linking against gstreamer libraries ubuntu 11.10

So I am starting a project that is going to make use of the gstreamer libraries. 所以我正在开始一个将使用gstreamer库的项目。 I am running the test project from the gstreamer documentation and am getting the following error.This program worked properly on archlinux but is erroring out on ubuntu 我从gstreamer文档运行测试项目,并得到以下错误。这个程序在archlinux上正常工作,但在ubuntu上出错了

gcc `pkg-config --cflags --libs gstreamer-0.10` main.c -o player
/tmp/cciFhGCe.o: In function `main':
main.c:(.text+0x1e): undefined reference to `gst_init'
main.c:(.text+0x36): undefined reference to `gst_version'
collect2: ld returned 1 exit status
make: *** [player] Error 1

My code is the following which I got from the gstreamer documentation 我的代码是我从gstreamer文档中获得的以下代码

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

int
main (int   argc,
      char *argv[])
{
  const gchar *nano_str;
  guint major, minor, micro, nano;

  gst_init (&argc, &argv);

  gst_version (&major, &minor, &micro, &nano);

  if (nano == 1)
    nano_str = "(CVS)";
  else if (nano == 2)
    nano_str = "(Prerelease)";
  else
    nano_str = "";

  printf ("This program is linked against GStreamer %d.%d.%d %s\n",
          major, minor, micro, nano_str);

  return 0;
}

and the command I am using to compile is 我用来编译的命令是

gcc `pkg-config --cflags --libs gstreamer-0.10` main.c -o player

and the output of pkg-config 和pkg-config的输出

-pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/gstreamer-0.10 -I/usr/include/libxml2  -pthread -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lxml2 -lgthread-2.0 -lrt -lglib-2.0

So thanks to the great guys on freenode #gstreamer 感谢freenode #gstreamer上的伟大人物

In unbuntu's version of gcc some changes were made to the ordering of pkg-config statements. 在unbuntu的gcc版本中,对pkg-config语句的顺序进行了一些更改。

gcc `pkg-config gstreamer-0.10 --cflags` main.c -o player.out `pkg-config gstreamer-0.10 --libs`

Using this format fixed it. 使用这种格式修复它。

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

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