If I run cargo test in a Rust project with rdkafka, I get the following error message:
[...]
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: Bibliothek "D:\Users\<...>\backend\target\debug\deps\api-99c334ee163d66a6.lib" und Objekt "D:\Users\<...>\backend\target\debug\deps\api-99c334ee163d66a6.exp" werden erstellt.␍
librdkafka_sys-ff0073d016e6a9d3.rlib(rdkafka_ssl.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "SSL_get_peer_certificate" in Funktion "rd_kafka_transport_ssl_verify".␍
D:\Users\<...>\backend\target\debug\deps\api-99c334ee163d66a6.exe : fatal error LNK1120: 1 nicht aufgelöste Externe
Cargo.toml:
[package]
name = "kafka"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
[dependencies]
# Error handling
anyhow.workspace = true
thiserror.workspace = true
# Serialization
serde = { workspace = true }
serde_json.workspace = true
# Async runtime
tokio.workspace = true
# Logging
tracing.workspace = true
# Kafka client
rdkafka = { version = "0.38", features = ["ssl", "cmake-build"] }
I have OpenSSL 3.6.0 installed on my windows machine and I used this script to build the project:
REM OpenSSL Environment Variables
set OPENSSL_DIR=C:\Program Files\OpenSSL-Win64
set OPENSSL_INCLUDE_DIR=C:\Program Files\OpenSSL-Win64\include
set OPENSSL_LIB_DIR=C:\Program Files\OpenSSL-Win64\lib\VC\x64
set OPENSSL_STATIC=1
cargo clean
cargo check
cargo test
I also tried this in Developer Command Prompt for VS 2022, because I found this in the internet.
I also installed this:
# Visual Studio Build Tools (Developer Command Prompt) - RUN AS ADMIN
winget install Microsoft.VisualStudio.2022.BuildTools --override "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
# CMake (for rdkafka cmake-build)
winget install Kitware.CMake
# Rust (stable-x86_64-pc-windows-msvc)
rustup default stable-x86_64-pc-windows-msvc
rustup update
I also tried the vcpkg way:
# Install vcpkg
git clone https://github.com/Microsoft/vcpkg.git C:\vcpkg
cd C:\vcpkg
.\bootstrap-vcpkg.bat
# Install OpenSSL
.\vcpkg install openssl:x64-windows
# Set environment variables (add to your PowerShell profile)
$env:OPENSSL_DIR = "C:\vcpkg\installed\x64-windows"
$env:OPENSSL_LIB_DIR = "$env:OPENSSL_DIR\lib"
$env:OPENSSL_INCLUDE_DIR = "$env:OPENSSL_DIR\include"
I made it work with one module some days ago, but now it doesn't work again.
Can you help me please?
If I run
cargo testin a Rust project with rdkafka, I get the following error message:Cargo.toml:
I have OpenSSL 3.6.0 installed on my windows machine and I used this script to build the project:
I also tried this in Developer Command Prompt for VS 2022, because I found this in the internet.
I also installed this:
I also tried the
vcpkgway:I made it work with one module some days ago, but now it doesn't work again.
Can you help me please?