提问人:Arjan 提问时间:3/22/2022 最后编辑:TsyvarevArjan 更新时间:3/29/2022 访问量:566
使用 CMake 构建 GStreamer 会导致 SDP 和 WebRTC 无法解析的外部符号错误
Building GStreamer with CMake causes SDP & WebRTC unresolved external symbol errors
问:
我正在使用 CMake 构建一个 C++ GStreamer 项目,它依赖于 GStreamer、GLIB、Libsoup 和 json-glib。我是 CMake 的新手,在设置我的项目时遇到问题。我已经设法包含了许多依赖项,但有些似乎仍未解决,即使它们是 GStreamer 的一部分。除 SDP 和 WebRTC 外,所有 GStreamer 方法和类型均已解析。据我所知,它们是 GStreamer 的一部分,也位于 GMake 正确“查找”的目录中。
这些是尝试生成项目时发生的错误。
[build] error LNK2019: unresolved external symbol __imp_gst_sdp_message_new referenced in function "void __cdecl soup_websocket_message_cb(struct _SoupWebsocketConnection *,enum SoupWebsocketDataType,struct _GBytes *,void *)" (?soup_websocket_message_cb@@YAXPEAU_SoupWebsocketConnection@@W4SoupWebsocketDataType@@PEAU_GBytes@@PEAX@Z)
[build] error LNK2019: unresolved external symbol __imp_gst_sdp_message_parse_buffer referenced in function "void __cdecl soup_websocket_message_cb(struct _SoupWebsocketConnection *,enum SoupWebsocketDataType,struct _GBytes *,void *)" (?soup_websocket_message_cb@@YAXPEAU_SoupWebsocketConnection@@W4SoupWebsocketDataType@@PEAU_GBytes@@PEAX@Z)
[build] error LNK2019: unresolved external symbol __imp_gst_sdp_message_as_text referenced in function "void __cdecl on_offer_created_cb(struct _GstPromise *,void *)" (?on_offer_created_cb@@YAXPEAU_GstPromise@@PEAX@Z)
[build] error LNK2019: unresolved external symbol __imp_gst_webrtc_session_description_get_type referenced in function "void __cdecl on_offer_created_cb(struct _GstPromise *,void *)" (?on_offer_created_cb@@YAXPEAU_GstPromise@@PEAX@Z)
[build] error LNK2019: unresolved external symbol __imp_gst_webrtc_session_description_new referenced in function "void __cdecl soup_websocket_message_cb(struct _SoupWebsocketConnection *,enum SoupWebsocketDataType,struct _GBytes *,void *)" (?soup_websocket_message_cb@@YAXPEAU_SoupWebsocketConnection@@W4SoupWebsocketDataType@@PEAU_GBytes@@PEAX@Z)
[build] error LNK2019: unresolved external symbol __imp_gst_webrtc_session_description_free referenced in function "void __cdecl on_offer_created_cb(struct _GstPromise *,void *)" (?on_offer_created_cb@@YAXPEAU_GstPromise@@PEAX@Z)
这是我的CMakeLists.txt
# CMakeList.txt : CMake project for stream-project, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)
project (stream-project LANGUAGES CXX)
# Packages
find_package(PkgConfig REQUIRED)
# Add source to this project's executable.
add_executable (${PROJECT_NAME} "main.cpp" "main.h")
# Search all modules that we so desire to use and "include_directories"
pkg_search_module(GST REQUIRED gstreamer-1.0 gstreamer-sdp-1.0 gstreamer-video-1.0 gstreamer-app-1.0 gstreamer-webrtc-1.0)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_search_module(LIBSOUP REQUIRED libsoup-2.4)
pkg_search_module(JSONGLIB REQUIRED json-glib-1.0)
include_directories(
${GST_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${LIBSOUP_INCLUDE_DIRS}
${JSONGLIB_INCLUDE_DIRS}
)
# Link target directories and libraries
target_link_directories(${PROJECT_NAME} PRIVATE
${GST_LIBRARY_DIRS}
${GLIB_LIBRARY_DIRS}
${LIBSOUP_LIBRARY_DIRS}
${JSONGLIB_LIBRARY_DIRS}
)
target_link_libraries(${PROJECT_NAME} PRIVATE
${GST_LIBRARIES}
${GLIB_LIBRARIES}
${LIBSOUP_LIBRARIES}
${JSONGLIB_LIBRARIES}
)
message(STATUS ${GST_INCLUDE_DIRS})
答:
1赞
Arjan
3/29/2022
#1
我设法通过使用我在网上找到的预制查找脚本来解决它。
https://chromium.googlesource.com/external/Webkit/+/master/Source/cmake/FindGStreamer.cmake
它创建了所有必要的定义,然后我包含和链接了这些定义。
这些是 FindGStreamer.cmake 文件中指定的默认值
FIND_GSTREAMER_COMPONENT(GSTREAMER_APP gstreamer-app-1.0 gst/app/gstappsink.h gstapp-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_AUDIO gstreamer-audio-1.0 gst/audio/audio.h gstaudio-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_FFT gstreamer-fft-1.0 gst/fft/gstfft.h gstfft-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_PBUTILS gstreamer-pbutils-1.0 gst/pbutils/pbutils.h gstpbutils-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_VIDEO gstreamer-video-1.0 gst/video/video.h gstvideo-1.0)
我用以下方法扩展了上面的内容:
FIND_GSTREAMER_COMPONENT(GSTREAMER_SDP gstreamer-sdp-1.0 gst/sdp/sdp.h gstsdp-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_WEBRTC gstreamer-webrtc-1.0 gst/webrtc/webrtc.h gstwebrtc-1.0)
评论
pkg-config --cflags --libs gstreamer-sdp-1.0