Summary
webrtc-sys/include/livekit/jsep.h:38 forward-declares class PeerContext;, but PeerContext is a cxx shared type defined on the Rust side as a struct (webrtc-sys/src/peer_connection.rs:213 → pub struct PeerContext(pub Box<dyn Any + Send>);, exposed via the cxx bridge type PeerContext; at line 208). So cxx generates struct PeerContext everywhere it emits C++.
Under the MSVC C++ ABI (x86_64-pc-windows-msvc, building the C++ with clang-cl or cl), the class vs struct tag is part of the mangled name (@V…@ for class vs @U…@ for struct). So:
jsep.cpp (which #includes jsep.h → sees class PeerContext) emits/refers to rust::Box<class PeerContext> symbols, while
- the cxx-generated
peer_connection.cc (sees the bridge struct PeerContext) emits rust::Box<struct PeerContext> symbols.
These mangle to different symbols → 4× LNK2019 unresolved external at link on windows-msvc:
LNK2019: unresolved external symbol ... rust::cxxbridge1::Box<PeerContext>::drop / ::from_raw / ::into_raw / ...
GCC and Clang (Linux/macOS, Itanium ABI) ignore the class/struct tag in mangling, so the symbols are identical there and this never surfaces — it's MSVC-ABI-only.
Fix (one word)
webrtc-sys/include/livekit/jsep.h:
namespace livekit_ffi {
-class PeerContext;
+struct PeerContext;
class IceCandidate {
jsep.h:38 is the only place in the crate that tags PeerContext as class; every other reference uses rust::Box<PeerContext> (untagged) and the cxx bridge declares it struct. Aligning the forward declaration to struct makes the tag consistent crate-wide.
This is a no-op on Linux/macOS (clang/gcc mangle class == struct), and resolves the link on windows-msvc.
Verification
With this one-line change applied (via a vendored crate + [patch.crates-io]) plus the documented windows-msvc +crt-static rustflag (to match the libwebrtc prebuilt's /MT), a downstream consumer links cleanly with webrtc-sys enabled on x86_64-pc-windows-msvc (CXX=clang-cl) and connects to a LiveKit room at runtime (rust SDK, screen-capture init OK).
Affected: webrtc-sys 0.3.x (verified identical in 0.3.21, 0.3.32, and current main).
Happy to open a PR with the one-line change if that's preferred.
Summary
webrtc-sys/include/livekit/jsep.h:38forward-declaresclass PeerContext;, butPeerContextis a cxx shared type defined on the Rust side as astruct(webrtc-sys/src/peer_connection.rs:213→pub struct PeerContext(pub Box<dyn Any + Send>);, exposed via the cxx bridgetype PeerContext;at line 208). So cxx generatesstruct PeerContexteverywhere it emits C++.Under the MSVC C++ ABI (
x86_64-pc-windows-msvc, building the C++ withclang-clorcl), theclassvsstructtag is part of the mangled name (@V…@forclassvs@U…@forstruct). So:jsep.cpp(which#includesjsep.h→ seesclass PeerContext) emits/refers torust::Box<class PeerContext>symbols, whilepeer_connection.cc(sees the bridgestruct PeerContext) emitsrust::Box<struct PeerContext>symbols.These mangle to different symbols → 4× LNK2019 unresolved external at link on windows-msvc:
GCC and Clang (Linux/macOS, Itanium ABI) ignore the class/struct tag in mangling, so the symbols are identical there and this never surfaces — it's MSVC-ABI-only.
Fix (one word)
webrtc-sys/include/livekit/jsep.h:namespace livekit_ffi { -class PeerContext; +struct PeerContext; class IceCandidate {jsep.h:38is the only place in the crate that tagsPeerContextasclass; every other reference usesrust::Box<PeerContext>(untagged) and the cxx bridge declares itstruct. Aligning the forward declaration tostructmakes the tag consistent crate-wide.This is a no-op on Linux/macOS (clang/gcc mangle
class==struct), and resolves the link on windows-msvc.Verification
With this one-line change applied (via a vendored crate +
[patch.crates-io]) plus the documented windows-msvc+crt-staticrustflag (to match the libwebrtc prebuilt's/MT), a downstream consumer links cleanly withwebrtc-sysenabled onx86_64-pc-windows-msvc(CXX=clang-cl) and connects to a LiveKit room at runtime (rust SDK, screen-capture init OK).Affected: webrtc-sys 0.3.x (verified identical in 0.3.21, 0.3.32, and current
main).Happy to open a PR with the one-line change if that's preferred.