Error: failed to run custom build command for `rdkafka-sys v4.5.0+1.9.2`

Caused by: process didn't exit successfully: target\debug\build\rdkafka-sys-5382ce5e35b02ace\build-script-build (exit code: 1)

--- stderr librdkafka will be linked dynamically librdkafka 1.9.2 cannot be found on the system: "pkg-config" "--libs" "--cflags" "rdkafka" "rdkafka >= 1.9.2" did not exit successfully: exit code: 1
error: could not find system library 'rdkafka' required by the 'rdkafka-sys' crate

--- stderr Package rdkafka was not found in the pkg-config search path. Perhaps you should add the directory containing rdkafka.pc' to the PKG_CONFIG_PATH environment variable No package 'rdkafka' found Package rdkafka was not found in the pkg-config search path. Perhaps you should add the directory containing rdkafka.pc' to the PKG_CONFIG_PATH environment variable No package 'rdkafka' found

Dynamic linking failed. Exiting.

I've tried various ways like set variable path, donwload librdkafka from github, set system variable but always failed or searching in stackoverflow but no answer or one case with me.

What do you get when you run pkg-config --libs --cflags rdkafka "rdkafka >= 1.9.2" at the command prompt? That must succeed.

pkg-config --libs --cflags rdkafka "rdkafka >= 1.9.2"
Package rdkafka was not found in the pkg-config search path.
Perhaps you should add the directory containing rdkafka.pc' to the PKG_CONFIG_PATH environment variable No package 'rdkafka' found Package rdkafka was not found in the pkg-config search path. Perhaps you should add the directory containing rdkafka.pc'
to the PKG_CONFIG_PATH environment variable
No package 'rdkafka' found

Sorry this is my first post so I'm figuring everything out lol. But if you're on Windows this might fix your problem.

I had this same problem and fixed it by making this change in my Cargo.toml file:
Before:
rdkafka = { version = "0.25", features = ["ssl-vendored"] }
After:

openssl = { version = "0.10.45", features = ["vendored"] }
rdkafka = { version = "0.25", features = ["cmake-build"] }

At the rdkafka-sys crates.io page they say "Windows is only supported when using the CMake build system via the cmake-build Cargo feature."

If you have problems with CMake even after installing it (I used VS Build Tools) I fixed it by appending CMake to my path like this in powershell: $Env:PATH += ";C:{cmake path here}\CMake\CMake\bin"

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.