gstreamer 链接错误(使用 gstglfilter 时)

gstreamer linking error (when using gstglfilter)

当我使用 CMake 构建我的 gstreamer 项目时,我使用以下 CmakeLists.txt:

cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 20)
include(FetchContent)

project(someproject)

find_package(PkgConfig REQUIRED)

pkg_check_modules(GST REQUIRED gstreamer-1.0>=1.4
        gstreamer-sdp-1.0>=1.4
        gstreamer-video-1.0>=1.4
        gstreamer-plugins-base-1.0>=1.4
        gstreamer-app-1.0>=1.4
        gstreamer-gl-1.0>=1.4)

#some other calls to find_package

add_library(someproject "")

#add source directories

target_include_directories(GUI_lib PUBLIC include "${OTHER_FIND_PACKAGE_INCLUDE_DIRS}"
        "${GST_INCLUDE_DIRS}")

target_link_libraries(someproject PUBLIC "${OTHER_FIND_PACKAGE_LIBS}" "${GST_LIBRARIES}"  -lGL -lepoxy)

这会导致以下错误:

in function `drawCallback(_GstElement*, unsigned int, unsigned int, unsigned int, void*)':
  undefined reference to `gst_gl_filter_get_type'
  undefined reference to `gst_gl_filter_draw_fullscreen_quad'

我已经搜索了我的 gstreamer 安装并确认存在一个使用以下代码段(星号表示强调)定义这些符号的共享库:

% readelf -s --wide /usr/lib/gstreamer-1.0/libgstopengl.so | rg gl_filter           
    121: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gst_gl_filter_render_to_target_with_shader
*   242: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gst_gl_filter_draw_fullscreen_quad
    305: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gst_gl_filter_add_rgba_pad_templates
    421: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gst_gl_filter_render_to_target
*   447: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gst_gl_filter_get_type
    470: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gst_gl_filter_filter_texture

因此,我将以下内容添加到我的 CMake 文件中:

add_library(gstopenglextras SHARED IMPORTED)
set_target_properties(gstopenglextras PROPERTIES
        IMPORTED_LOCATION "/usr/lib/gstreamer-1.0/libgstopengl.so")

我还将 target_link_libraries 调用更改为:

target_link_libraries(someproject PUBLIC "${OTHER_FIND_PACKAGE_LIBS}" gstopenglextras "${GST_LIBRARIES}" -lGL -lepoxy)

现在我收到以下链接器错误:

/usr/bin/ld: undefined reference to symbol 'gst_gl_filter_get_type'
/usr/bin/ld: /usr/lib/libgstgl-1.0.so.0: error adding symbols: DSO missing from command line

我已经阅读了一些关于循环依赖的资料,并且尝试在 gstopenglextras 之前添加 "${GST_LIBRARIES}"。但是,这不会改变错误。

有什么想法吗?

target_link_libraries(
  someproject
  PUBLIC
    "${OTHER_FIND_PACKAGE_LIBS}"
    gstopenglextras
    "${GST_LIBRARIES}"
    -lGL
    -lepoxy
    gstgl-1.0
    glib-2.0
    gmodule-2.0
)

是解决此问题的电话。