编译 gst-rtsp-server 示例时出错

编译 gst-rtsp-server 示例时出错

我目前正在尝试设置一个 Ubuntu 服务器来重新分配来自 IP 摄像机的 rtsp 馈送。

我看到gst-rtsp-server 库gstreamer 可以帮助我解决这个问题。

我安装了以下包:

sudo apt-get install libgstrtspserver-1.0-dev
sudo apt-get install gstreamer1.0-rtsp
sudo apt-get install libglib2.0-dev

然后我在我的桌面上克隆了 gst-rtsp-server 库 repo:

git clone https://github.com/GStreamer/gst-rtsp-server.git

但是,当我尝试编译一个 C 文件(gst-rtsp-server/examples/test-launch.c)时,该示例说明了如何使用 gcc 的库:

gcc test-launch.c -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include

我收到以下错误:

/tmp/ccM7e45N.o: In function `main':
test-launch.c:(.text+0x2e): undefined reference to `g_option_context_new'
test-launch.c:(.text+0x4a): undefined reference to `g_option_context_add_main_entries'
test-launch.c:(.text+0x4f): undefined reference to `gst_init_get_option_group'
test-launch.c:(.text+0x61): undefined reference to `g_option_context_add_group'
test-launch.c:(.text+0x79): undefined reference to `g_option_context_parse'
test-launch.c:(.text+0x99): undefined reference to `g_printerr'
test-launch.c:(.text+0xa5): undefined reference to `g_option_context_free'
test-launch.c:(.text+0xb1): undefined reference to `g_clear_error'
test-launch.c:(.text+0xc7): undefined reference to `g_option_context_free'
test-launch.c:(.text+0xd6): undefined reference to `g_main_loop_new'
test-launch.c:(.text+0xdf): undefined reference to `gst_rtsp_server_new'
test-launch.c:(.text+0x107): undefined reference to `g_object_set'
test-launch.c:(.text+0x113): undefined reference to `gst_rtsp_server_get_mount_points'
test-launch.c:(.text+0x11c): undefined reference to `gst_rtsp_media_factory_new'
test-launch.c:(.text+0x13a): undefined reference to `gst_rtsp_media_factory_set_launch'
test-launch.c:(.text+0x14b): undefined reference to `gst_rtsp_media_factory_set_shared'
test-launch.c:(.text+0x162): undefined reference to `gst_rtsp_mount_points_add_factory'
test-launch.c:(.text+0x16e): undefined reference to `g_object_unref'
test-launch.c:(.text+0x17f): undefined reference to `gst_rtsp_server_attach'
test-launch.c:(.text+0x19a): undefined reference to `g_print'
test-launch.c:(.text+0x1a6): undefined reference to `g_main_loop_run'
collect2: error: ld returned 1 exit status

我错过了一些东西,但我不知道是什么……><'

该错误显然是由于缺少标题而引起的,但是哪一个以及在哪里可以找到它?

一如往常,感谢您的帮助/提示!

答案1

如果这返回了一些内容:

pkg-config --modversion gstreamer-rtsp-server-1.0

(对我来说,它返回1.14.1

您可以使用以下 gcc 命令来编译所需的示例:

gcc -o test-launch  test-launch.c  `pkg-config --cflags --libs gstreamer-rtsp-server-1.0`

PS 在命令中,请确保使用反引号 ` 而不是撇号 '

来源: https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html#hello-world

相关内容