Installing the Rust Bindings
The Rust bindings link against the AstuteDDS static library
(libastutedds.a), so a working AstuteDDS installation must be present
before the crates can build. Two install paths are supported.
Add the crates to your project
Point Cargo.toml at the in-tree crates:
[dependencies]
astutedds = { path = "/path/to/astutedds-cxx/bindings/rust/astutedds" }
The astutedds crate re-exports the raw astutedds-sys FFI for advanced
use cases; add it directly if you need to call the C API yourself:
[dependencies]
astutedds = { path = "/path/to/astutedds-cxx/bindings/rust/astutedds" }
astutedds-sys = { path = "/path/to/astutedds-cxx/bindings/rust/astutedds-sys" }
Building with cargo
astutedds-sys's build.rs locates libastutedds.a through two
environment variables:
| Variable | Purpose |
|---|---|
ASTUTEDDS_LIB_DIR |
Directory containing libastutedds.a (e.g. build/lib). |
CMAKE_BINARY_DIR |
Optional fall-back used when ASTUTEDDS_LIB_DIR is not set. |
Typical workflow:
# 1. Build the C++ static library
cd astutedds-cxx
cmake -S . -B build
cmake --build build -j
# 2. Build your Rust project against it
cd /path/to/my_rust_app
ASTUTEDDS_LIB_DIR=/path/to/astutedds-cxx/build/lib cargo build --release
Building via CMake
Pass -DASTUTEDDS_BUILD_RUST=ON and CMake will drive cargo build for
both crates after libastutedds.a is produced, then install the resulting
.rlib files to ${CMAKE_INSTALL_PREFIX}/lib/astutedds/rust/:
cmake -S . -B build -DASTUTEDDS_BUILD_RUST=ON
cmake --build build -j
sudo cmake --install build
Supported toolchain
| Item | Version |
|---|---|
| Rust | stable, 1.75+ |
| Edition | 2021 |
| Linker | matches the C++ toolchain (system cc/clang/MSVC) |
Uninstalling
# Built via CMake
sudo cmake --build build --target uninstall
# Path-dependency in your own project
cargo clean