Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
freerdp-sys
Low-level Rust FFI bindings to FreeRDP 3.x — a free, open-source implementation of the Remote Desktop Protocol (RDP).
Overview
freerdp-sys is a general-purpose, standalone -sys crate that exposes the FreeRDP 3.x C API
to Rust. It is not tied to any specific application or framework — any Rust project that needs RDP
client or server functionality can build on top of it.
Key characteristics:
- Bindings generated via
bindgenfrom FreeRDP 3.x headers - Vendored CMake build compiles FreeRDP from source (zero system dependencies at link time)
- Optional system linking via
pkg-configfor distro-packaged FreeRDP - Pre-generated bindings included so downstream users don't need
libclang - Dual-licensed (MIT / Apache-2.0) for maximum compatibility
Installation
Vendored build (default, recommended)
Compiles FreeRDP 3.x from source during cargo build. No system FreeRDP installation required.
[]
= "0.1"
System linking
Links against a system-installed FreeRDP 3.x discovered via pkg-config.
[]
= { = "0.1", = false, = ["system"] }
With runtime binding generation
Generates fresh bindings at build time using bindgen (requires libclang).
[]
= { = "0.1", = ["generate-bindings"] }
Feature Flags
| Feature | Default | Description |
|---|---|---|
vendored |
✓ | Compile FreeRDP 3.x from vendored source via CMake. Produces static libraries. |
system |
Link against a system-installed FreeRDP 3.x discovered via pkg-config. |
|
generate-bindings |
Run bindgen at build time to regenerate FFI bindings (requires libclang). When disabled, pre-generated src/bindings.rs is used. |
Note:
vendoredandsystemare mutually exclusive. Enable exactly one.
Requirements
Vendored build
| Dependency | Minimum Version | Purpose |
|---|---|---|
| CMake | 3.13 | Build system for FreeRDP |
| C compiler | C11 | gcc, clang, or MSVC |
| OpenSSL | 1.1.1+ | TLS/crypto support |
| zlib | 1.2+ | Compression |
| Rust | 1.77+ | Crate MSRV |
Platform-specific:
- Linux:
libssl-dev,zlib1g-dev,cmake,build-essential - macOS:
brew install cmake openssl zlib - Windows: Visual Studio Build Tools, vcpkg OpenSSL + zlib
System linking
- FreeRDP 3.x development packages (
libfreerdp3-devor equivalent) pkg-config- WinPR 3.x development packages
Binding generation (optional)
libclang(used by thebindgencrate)- Linux:
libclang-dev - macOS:
brew install llvm(setLIBCLANG_PATHif needed)
- Linux:
Usage
use *;
Safety: All functions in this crate are
unsafeFFI calls. Refer to the FreeRDP API documentation for correct usage, memory ownership, and threading constraints.
Build Configuration
Environment Variables
| Variable | Description | Example |
|---|---|---|
FREERDP_CMAKE_DEFS |
Extra CMake definitions (semicolon-separated) | WITH_CAIRO=ON;WITH_FFMPEG=ON |
FREERDP_BINDGEN_CLANG_ARGS |
Extra clang arguments passed to bindgen | -DWITH_SMARTCARD=1 |
LIBCLANG_PATH |
Path to libclang (if not in default search path) | /usr/lib/llvm-18/lib |
CMAKE |
Path to cmake binary | /usr/local/bin/cmake |
CMake Build Options
The vendored build configures FreeRDP with these defaults (optimized for a minimal static library):
BUILD_SHARED_LIBS=OFF WITH_SERVER=OFF
WITH_CLIENT=OFF WITH_CHANNELS=OFF
WITH_WINPR_TOOLS=OFF WITH_MANPAGES=OFF
BUILD_TESTING=OFF WITH_SAMPLE=OFF
WITH_PROXY=OFF WITH_SHADOW=OFF
CMAKE_BUILD_TYPE=Release
Override any of these via FREERDP_CMAKE_DEFS:
FREERDP_CMAKE_DEFS="WITH_SERVER=ON;WITH_CHANNELS=ON"
Development
Getting Started
# Clone with submodule
# Or initialize submodule after clone
Building
# Default vendored build (pre-generated bindings)
# Vendored + regenerate bindings from headers
# System linking
# Check without linking (uses pre-generated bindings)
Testing
Regenerating Pre-built Bindings
# Using the helper script
# Or manually
Project Structure
freerdp-sys/
├── Cargo.toml # Crate manifest with feature flags & crates.io metadata
├── build.rs # Build script: cmake vendored build + bindgen orchestration
├── src/
│ ├── lib.rs # Crate root: conditional binding inclusion, docs
│ ├── bindings.rs # Pre-generated bindings (no libclang needed by consumers)
│ └── wrapper.h # C header input for bindgen (FreeRDP 3.x + WinPR)
├── vendor/
│ └── FreeRDP/ # Git submodule → FreeRDP 3.x source (stable-3.0)
├── cmake/
│ └── CMakeLists.txt # Optional CMake wrapper for standalone/test builds
├── scripts/
│ └── regenerate-bindings.sh # Helper to regenerate src/bindings.rs
├── .github/workflows/
│ └── ci.yml # CI: check, clippy, test, fmt, publish
├── .gitmodules # Submodule config (FreeRDP stable-3.0)
├── rustfmt.toml # Formatting configuration
├── LICENSE-MIT # MIT license
├── LICENSE-APACHE # Apache 2.0 license
└── README.md # This file
Troubleshooting
"vendored FreeRDP source not found"
freerdp-sys: vendored FreeRDP source not found at `vendor/FreeRDP`.
Fix: Initialize the git submodule:
"could not find FreeRDP 3.x via pkg-config"
freerdp-sys: could not find FreeRDP 3.x via pkg-config.
Fix: Install FreeRDP 3.x development packages:
# Debian/Ubuntu
# Fedora
# Or switch to vendored build
bindgen / libclang errors
thread 'main' panicked: Unable to find libclang
Fix: Install libclang and set the path:
# Linux
# macOS
CMake not found
Failed to run cmake: No such file or directory
Fix: Install CMake ≥ 3.13:
# Linux
# macOS
# Or set CMAKE env var
Linker errors (missing symbols)
If you see undefined symbol errors at link time, ensure all platform dependencies are installed:
# Linux
# macOS (if using Homebrew OpenSSL)
Publishing to crates.io
This crate is configured for automated publishing via GitHub Actions on tag push:
# Tag a release
# CI will run checks, then publish to crates.io
Manual publishing:
Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repository and create a feature branch
- Initialize submodules:
git submodule update --init --recursive - Make your changes following the existing code style
- Format:
cargo fmt --all - Check:
cargo clippy --features vendored,generate-bindings - Test:
cargo test --features vendored,generate-bindings - Commit with a descriptive message
- Open a Pull Request against
main
Code Style
- Follow
rustfmtdefaults (configured inrustfmt.toml) - All public items must have doc comments
- Unsafe code must have safety comments explaining invariants
- Keep bindings generation reproducible — commit updated
src/bindings.rswhen headers change
Reporting Issues
When reporting bugs, please include:
- OS and architecture
- Rust version (
rustc --version) - Feature flags used
- Full error output
- CMake version (for vendored builds)
License
Licensed under either of:
- MIT License (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate shall be dual licensed as above, without any additional terms or conditions.