c - 使用 autotools 链接 gstreamer 插件中的外部库

标签 c gstreamer autotools automake libtool

我使用 gstreamer 插件编写者指南 (http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-building-boiler.html) 中引用的样板模板编写了一个 gstreamer 插件。我首先在没有完全实现链功能的情况下构建插件(基本上是一个空插件,将数据从源传递到接收器,没有任何更改)。

我现在正在实现链函数以对缓冲区中的数据执行基本过滤。过滤使用外部锐化库(我已在 gstreamer 之外成功使用)。使用 autotools 构建时没有出现错误,但是使用新插件创建管道时出现 undefined symbol 错误

(gst-plugin-scanner:6512): GStreamer-WARNING **: Failed to load plugin '/usr/local/lib/gstreamer-1.0/libgstsharpening.so': /usr/local/lib/gstreamer-1.0/libgstsharpening.so: undefined symbol: InitializeSharpeningModule

诚然,我对 autotools 非常陌生,我相信我的问题出在那个过程中的某个地方,但我无法弄清楚在哪里。可以在此处找到正在使用的外部锐化库

/public/gstreamer_pipeline/lib/libsharpening.so

我为我的插件编辑了在 src 目录中找到的插件 Makefile.am

/public/gstreamer_pipeline/src/gst-sharpening/src

修改后的Makefile.am内容为

plugin_LTLIBRARIES = libgstsharpening.la

libgstsharpening_la_SOURCES = gstsharpening.c gstsharpening.h

libgstsharpening_la_CFLAGS = $(GST_CFLAGS) -I/public/gstreamer_pipeline/include
libgstsharpening_la_LIBADD = $(GST_LIBS) -lsharpening
libgstsharpening_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -L/public/gstreamer_pipeline/lib
libgstsharpening_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)

noinst_HEADERS = gstsharpening.h

undefined symbol 错误发生在从主程序创建管道的情况下,或者从命令行使用创建管道

gst-launch-1.0 fakesrc ! sharpening ! fakesink

在新创建的插件库(不修改 LD_LIBRARY_PATH)上运行 ldd 的输出是

ldd /usr/local/lib/gstreamer-1.0/libgstsharpening.so
    linux-vdso.so.1 =>  (0x00007fff17bc0000)
    libgstbase-1.0.so.0 => /usr/local/lib/libgstbase-1.0.so.0 (0x00007f3c51778000)
    libgstcontroller-1.0.so.0 => /usr/local/lib/libgstcontroller-1.0.so.0 (0x00007f3c51568000)
    libgstreamer-1.0.so.0 => /usr/local/lib/libgstreamer-1.0.so.0 (0x00007f3c51250000)
    libgmodule-2.0.so.0 => /usr/local/lib/libgmodule-2.0.so.0 (0x00007f3c5104d000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f3c50db0000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f3c50bac000)
    libgobject-2.0.so.0 => /usr/local/lib/libgobject-2.0.so.0 (0x00007f3c5095f000)
    libffi.so.6 => /usr/local/lib/../lib64/libffi.so.6 (0x00007f3c50755000)
    libglib-2.0.so.0 => /usr/local/lib/libglib-2.0.so.0 (0x00007f3c50420000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3c50203000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f3c4fffa000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f3c4fc67000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003406c00000)

configure.log 输出 http://pastie.org/10450341

make 和 make install 的输出 http://pastie.org/10450352

最佳答案

很可能运行时链接器/加载器无法在非标准路径 (/public/gstreamer_pipeline/lib/) 中找到辅助库 (libsharpening.so)。

(您告诉 automake 在构建过程中的链接步骤中在哪里寻找该库;这并不意味着运行时链接器会查找相同的库地点)。

有多种方法可以解决这个问题:

  • 将库安装在运行时链接器将查找它的地方,例如/usr/local/lib/(这是好方法)

    • 将运行时链接器配置为在您的非标准路径中永久查找库,方法是将其添加到 /etc/ld.so.config(或者 - 如果您的系统支持它 - 添加它到新文件 /etc/ld.so.conf.d/gstreamer_pipeline.conf)
  • 通过 LD_LIBRARY_PATH 环境变量告诉运行时链接器使用附加路径进行库解析。

例如

LD_LIBRARY_PATH=/public/gstreamer_pipeline/lib/ gst-launch-1.0 \
          fakesrc ! sharpening ! fakesink

关于c - 使用 autotools 链接 gstreamer 插件中的外部库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32825881/

相关文章:

c - x86 汇编中 "imul"指令的不熟悉语法

c - 如何将 argv[] 值从 main 传递到外部函数

cross-compiling - Autotools 交叉编译和生成源

linux - autotools 中的 automake 错误消息

宏可以执行复合赋值吗

ffmpeg - 一个创建 HLS 流的类轮

python - 在 EOS 上用 Python 重启 GStreamer 管道

ffmpeg - 如何创建 gstreamer 插件以识别 mpeg2ts 中的私有(private)流?

cross-compiling - 使用 autotools 交叉编译时使用 ccache

c - 我如何使用 Opencv SparseMatrix