在静态可执行文件中加载 gstreamer 插件
Loading gstreamer plugins in static executable
我需要使用 gstreamer 构建静态 Linux 可执行文件,并使用作为 coreelements 插件一部分的队列工厂。我所做的是:
- 已配置 gstreamer(版本 1.12.4):
./configure --enable-static --disable-shared --enable-static-plugins
- 构建它和 gst-plugin-base
- 在我的代码中添加:
GST_PLUGIN_STATIC_DECLARE(coreelements);
GST_PLUGIN_STATIC_REGISTER(coreelements);
- 将我的应用与 libgstcoreelements.a 链接(连同 gstreamer-1.0、gstbase-1.0 和 gstapp-1.0)
链接失败:
undefined reference to gst_plugin_coreelements_register()
我可以验证gst_plugin_coreelements_register
在静态库文件中:
$ nm libgstcoreelements.a |grep gst_plugin_coreelements_register
00000000000002c0 T gst_plugin_coreelements_register
你看到我哪里做错了吗?
我缺少的是第一个 gstreamer 宏周围的 extern "C" { }
块,因为它声明了一个 extern C-style 函数,我的应用程序是用 g++ 编译的:
extern "C" {
GST_PLUGIN_STATIC_DECLARE(coreelements);
}
我需要使用 gstreamer 构建静态 Linux 可执行文件,并使用作为 coreelements 插件一部分的队列工厂。我所做的是:
- 已配置 gstreamer(版本 1.12.4):
./configure --enable-static --disable-shared --enable-static-plugins
- 构建它和 gst-plugin-base
- 在我的代码中添加:
GST_PLUGIN_STATIC_DECLARE(coreelements); GST_PLUGIN_STATIC_REGISTER(coreelements);
- 将我的应用与 libgstcoreelements.a 链接(连同 gstreamer-1.0、gstbase-1.0 和 gstapp-1.0)
链接失败:
undefined reference to gst_plugin_coreelements_register()
我可以验证gst_plugin_coreelements_register
在静态库文件中:
$ nm libgstcoreelements.a |grep gst_plugin_coreelements_register
00000000000002c0 T gst_plugin_coreelements_register
你看到我哪里做错了吗?
我缺少的是第一个 gstreamer 宏周围的 extern "C" { }
块,因为它声明了一个 extern C-style 函数,我的应用程序是用 g++ 编译的:
extern "C" {
GST_PLUGIN_STATIC_DECLARE(coreelements);
}