场景

undefined symbol: public: virtual bool __cdecl rtc::FileRotatingLogSink::Init(void) peerconnection_client


原因

当前采用ninja工具对代码进行编译,因此按照传统的VS添加lib文件无效


修改编译脚本

src\examples\BUILD.gn

增加源码文件"../rtc_base:log_sinks", 

  rtc_executable("peerconnection_client") {
    testonly = true
    sources = [
      "peerconnection/client/conductor.cc",
      "peerconnection/client/conductor.h",
      "peerconnection/client/defaults.cc",
      "peerconnection/client/defaults.h",
      "peerconnection/client/peer_connection_client.cc",
      "peerconnection/client/peer_connection_client.h",
    ]

    deps = [
      "../api:audio_options_api",
      "../api:create_peerconnection_factory",
      "../api:libjingle_peerconnection_api",
      "../api:media_stream_interface",
      "../api:rtp_sender_interface",
      "../api:scoped_refptr",
      "../api/audio:audio_mixer_api",
      "../api/audio_codecs:audio_codecs_api",
      "../api/task_queue:pending_task_safety_flag",
      "../api/units:time_delta",
      "../api/video:video_frame",
      "../api/video:video_rtp_headers",
      "../api/video_codecs:video_codecs_api",
      "../media:media_channel",
      "../media:rtc_media_base",
      "../p2p:rtc_p2p",
      "../pc:video_track_source",
      "../rtc_base:checks",
      "../rtc_base:logging", 
      "../rtc_base:log_sinks", 
      "../rtc_base:macromagic",
      "../rtc_base:net_helpers",
      "../rtc_base:refcount",
      "../rtc_base:rtc_certificate_generator",
      "../rtc_base:ssl",
      "../rtc_base:stringutils",
      "../rtc_base:threading",
      "../rtc_base/third_party/sigslot",
      "../system_wrappers:field_trial",
      "../test:field_trial",
      "../test:platform_video_capturer",
      "../test:rtp_test_utils",
      "//third_party/abseil-cpp/absl/memory",
      "//third_party/abseil-cpp/absl/types:optional",
    ]
    if (is_win) {
      sources += [
        "peerconnection/client/flag_defs.h",
        "peerconnection/client/main.cc",
        "peerconnection/client/main_wnd.cc",
        "peerconnection/client/main_wnd.h",
      ]
      configs += [ "//build/config/win:windowed" ]
      deps += [
        "../media:rtc_media_base",
        "../rtc_base:win32",
        "../rtc_base:win32_socket_init",
      ]
    }
    if (is_linux || is_chromeos) {
      sources += [
        "peerconnection/client/linux/main.cc",
        "peerconnection/client/linux/main_wnd.cc",
        "peerconnection/client/linux/main_wnd.h",
      ]
      cflags = [ "-Wno-deprecated-declarations" ]
      libs = [
        "X11",
        "Xcomposite",
        "Xext",
        "Xrender",
      ]
      configs += [ ":gtk_config" ]
    }

    deps += [
      "../api:libjingle_peerconnection_api",
      "../api/audio_codecs:builtin_audio_decoder_factory",
      "../api/audio_codecs:builtin_audio_encoder_factory",
      "../api/video:video_frame",
      "../api/video:video_rtp_headers",
      "../api/video_codecs:video_decoder_factory_template",
      "../api/video_codecs:video_decoder_factory_template_dav1d_adapter",
      "../api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter",
      "../api/video_codecs:video_decoder_factory_template_libvpx_vp9_adapter",
      "../api/video_codecs:video_decoder_factory_template_open_h264_adapter",
      "../api/video_codecs:video_encoder_factory_template",
      "../api/video_codecs:video_encoder_factory_template_libaom_av1_adapter",
      "../api/video_codecs:video_encoder_factory_template_libvpx_vp8_adapter",
      "../api/video_codecs:video_encoder_factory_template_libvpx_vp9_adapter",
      "../api/video_codecs:video_encoder_factory_template_open_h264_adapter",
      "../media:rtc_audio_video",
      "../modules/audio_device",
      "../modules/audio_processing",
      "../modules/audio_processing:api",
      "../modules/video_capture:video_capture_module",
      "../pc:libjingle_peerconnection",
      "../rtc_base:rtc_json",
      "../test:video_test_common",
      "//third_party/abseil-cpp/absl/flags:flag",
      "//third_party/abseil-cpp/absl/flags:parse",
      "//third_party/libyuv",
    ]
  }


问题

rebuilding 'build.ninja': subcommand failed peerconnection_client

1>You got a tab character in here. Tabs are evil. Convert to spaces.

1>ninja : error : rebuilding 'build.ninja': subcommand failed

解决

"../rtc_base:log_sinks",前面存在tab,需要缩进到前面,然后空格键填充对齐