livekit / rust-sdks

LiveKit realtime and server SDKs for Rust
https://livekit.io
Apache License 2.0
185 stars 44 forks source link

windows: libwebrtc-sys conflicts with other crates that use C/C++ #364

Open maxbrunsfeld opened 2 months ago

maxbrunsfeld commented 2 months ago

It looks like the prebuilt WebRTC library downloaded by the libwebrtc-sys build links the windows C Runtime Library statically, as opposed to dynamically, which causes linker errors when using other Rust crates that link to the C Runtime Library.

When compiling an application that uses both LiveKit and other crates that include C code via build.rs and the cc crate, the Zed project is getting a large number of linker errors like this:

libcpmt.lib(xstol.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in libtree_sitter_yaml-df6b0adf8f009e8f.rlib(2e40c9e35e9506f4-scanner.o)

Here is the CI build where this error (and many similar ones) occurred.

The error mentions an object file libtree_sitter_yaml-..-scanner.o, which is just one of the crates that Zed depends on that uses C++. Here is the build.rs for that crate. You can see it's pretty standard - just including some C code via the cc crate.