cloudflare / quiche

🥧 Savoury implementation of the QUIC transport protocol and HTTP/3
https://docs.quic.tech/quiche/
BSD 2-Clause "Simplified" License
9.4k stars 709 forks source link

C/C++ Quiche Multi-threaded Debug DLL Runtime on Windows #1283

Open maxsharabayko opened 2 years ago

maxsharabayko commented 2 years ago

My question is probably RUST-specific, still, I haven't found a solution. I hope there is some RUST for Windows expert here who could advise how to build quiche with Multi-threaded Debug DLL configuration.

I am building the quiche library on Windows to link it into my C++ project. The build command bellow produces a library and places it in a 'debug' folder, but the runtime is MD_DynamicRelease (Multi-threaded DLL). I can successfully link the library to my project in a Release configuration but have a runtime library mismatch when building my project in a Debug configuration.

cargo build --examples --features ffi

I tried adding a dev profile to the main Cargo.toml file, didn't help.

[profile.dev]
opt-level = 0
debug = true
maxsharabayko commented 2 years ago

A Small Update on the Topic

There is a related discussion on debug builds on windows with rust here: https://github.com/rust-lang/rust/issues/39016. RUST has not solved this issue yet. However, there is a workaround: setting CFLAGS and CXXFLAGS in the CMD environment to -MDd before doing cargo build.

Tried with quiche. Almost worked. Now stuck in BoringSSL being built with different flags (running from cargo). Maybe build.rs has to be modified somehow 🤔

set CFLAGS=-MDd
set CXXFLAGS=-MDd
cargo build --examples --features ffi

(...)

  = note:    Creating library d:\Projects\quic\quiche-2\target\debug\deps\quiche.dll.lib and object d:\Projects\quic\quiche-2\target\debug\deps\quiche.dll.exp
          LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
          ssl.lib(encrypted_client_hello.obj) : error LNK2019: unresolved external symbol __imp__invalid_parameter referenced in function "bool __cdecl bssl::is_ipv4_address(class bssl::Span<unsigned char const >)" (?is_ipv4_address@bssl@@YA_NV?$Span@$$CBE@1@@Z)
          ssl.lib(encrypted_client_hello.obj) : error LNK2019: unresolved external symbol __imp__CrtDbgReport referenced in function "bool __cdecl bssl::is_ipv4_address(class bssl::Span<unsigned char const >)" (?is_ipv4_address@bssl@@YA_NV?$Span@$$CBE@1@@Z)
          d:\Projects\quic\quiche-2\target\debug\deps\quiche.dll : fatal error LNK1120: 2 unresolved externals

error: could not compile `quiche` due to previous error