WebRTC 编译时使用参数use_custom_libcxx=false报错问题

510 阅读2分钟

背景

CentOS 系统中编译 WebRTC 时使用参数 use_custom_libcxx=false 报错。

命令:

gn gen out/Release --args='is_debug=false target_os="linux" target_cpu="x64" rtc_include_tests=false is_component_build=false rtc_build_tools=false rtc_build_examples=false rtc_enable_protobuf=false rtc_use_h264=true use_custom_libcxx=false use_rtti=true'

报错:

../../modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc:552:10: error: no matching member function for call to 'emplace'
  552 |   config.emplace();
      |   ~~~~~~~^~~~~~~
../../build/linux/debian_bullseye_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/optional:848:2: note: candidate template ignored: requirement 'is_constructible_v<webrtc::LossBasedBweV2::Config>' was not satisfied [with _Args = <>]
  848 |         emplace(_Args&&... __args)
      |         ^
../../build/linux/debian_bullseye_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/optional:858:2: note: candidate function template not viable: requires at least argument '__il', but no arguments were provided
  858 |         emplace(initializer_list<_Up> __il, _Args&&... __args)
      |         ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

解决方法

webrtc::LossBasedBweV2::Config 声明一个默认构造函数

修改 modules/congestion_controller/goog_cc/loss_based_bwe_v2.h

struct Config 中新增构造函数 Config();

修改 modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc

新增构造函数的实现,注意类变量需要一致。

LossBasedBweV2::Config::Config()
    : bandwidth_rampup_upper_bound_factor(0.0),
      bandwidth_rampup_upper_bound_factor_in_hold(0),
      bandwidth_rampup_hold_threshold(0),
      rampup_acceleration_max_factor(0.0),
      rampup_acceleration_maxout_time(TimeDelta::Zero()),
      candidate_factors(),
      higher_bandwidth_bias_factor(0.0),
      higher_log_bandwidth_bias_factor(0.0),
      inherent_loss_lower_bound(0.0),
      loss_threshold_of_high_bandwidth_preference(0.0),
      bandwidth_preference_smoothing_factor(0.0),
      inherent_loss_upper_bound_bandwidth_balance(DataRate::MinusInfinity()),
      inherent_loss_upper_bound_offset(0.0),
      initial_inherent_loss_estimate(0.0),
      newton_iterations(0),
      newton_step_size(0.0),
      append_acknowledged_rate_candidate(true),
      append_delay_based_estimate_candidate(false),
      append_upper_bound_candidate_in_alr(false),
      observation_duration_lower_bound(TimeDelta::Zero()),
      observation_window_size(0),
      sending_rate_smoothing_factor(0.0),
      instant_upper_bound_temporal_weight_factor(0.0),
      instant_upper_bound_bandwidth_balance(DataRate::MinusInfinity()),
      instant_upper_bound_loss_offset(0.0),
      temporal_weight_factor(0.0),
      bandwidth_backoff_lower_bound_factor(0.0),
      max_increase_factor(0.0),
      delayed_increase_window(TimeDelta::Zero()),
      not_increase_if_inherent_loss_less_than_average_loss(false),
      not_use_acked_rate_in_alr(false),
      use_in_start_phase(false),
      min_num_observations(0),
      lower_bound_by_acked_rate_factor(0.0),
      hold_duration_factor(0.0),
      use_byte_loss_rate(false),
      padding_duration(TimeDelta::Zero()),
      bound_best_candidate(false),
      pace_at_loss_based_estimate(false) {}

参考

  1. stackoverflow.com/questions/7…
  2. github.com/llvm/llvm-p…