A Rust cross-platform library demonstrating how to create native bindings for other programming languages.
This project serves as an example of building a Rust library that can be consumed from other languages through FFI (Foreign Function Interface). The library is compiled to both dynamic (cdylib) and static (staticlib) formats to support different integration scenarios.
- Cross-platform compatibility
- Native library bindings
- Example implementations for language interoperability
- Clean C-compatible API surface
- Build the library using Cargo:
cargo build --release- Link & run using e.g. the example Swift program:
cd bindings/swift && bash build.sh && ./swift_test_static
Testing Rust FFI Library from Swift:
Magic number: 42
Random number (1-10): 4
5 + 7 = 12This project is dual-licensed under Apache 2.0 and MIT licenses.