Search code examples
rustrust-cargo

Rust compilation error " failed to run custom build command for `rdkafka-sys v4.8.0+2.3.0`' " win 10


error: failed to run custom build command for `rdkafka-sys v4.8.0+2.3.0`

Caused by:
  process didn't exit successfully: `C:\zzy\work\rust\project\hyperswitch-main\target\debug\build\rdkafka-sys-5b6b43e37e2633c5\build-script-build` (exit code: 101)
  --- stdout
  Cloning librdkafka

  --- stderr
  Building and linking librdkafka statically
  Running command: "cp -a librdkafka/. C:\zzy\work\rust\project\hyperswitch-main\target\debug\build\rdkafka-sys-d0fe0d1747dfd315\out" in dir: .

  thread 'main' panicked at C:\Users\PC\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rdkafka-sys-4.8.0+2.3.0\build.rs:38:19:
  Command failed with error: program not found
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

How do I fix this error?


Solution

  • According to rdkafka-sys's README:

    Build

    Known issues

    • Windows is only supported when using the CMake build system via the cmake-build Cargo feature.

    Assuming you're using rdkafka rather than rdkafka-sys directly, enable the cmake-build feature by writing your dependency like this in Cargo.toml:

    [dependencies]
    rdkafka = { version = "0.37", features = ["cmake-build"] }