Files
zerokit/rln/ffi_c_examples/Readme.md

938 B

RLN FFI C example

This example demonstrates how to use the RLN C FFI in both stateless and non-stateless modes.

Non-stateless mode

Compile lib non-stateless

cargo build -p rln
cargo run --features headers --bin generate-headers
mv -v rln.h rln/ffi_c_examples/

Compile and run example non-stateless

cd rln/ffi_c_examples/
gcc -Wall main.c -o main -lrln -L../../target/debug
./main

Stateless mode

Compile lib stateless

cargo build -p rln --no-default-features --features stateless
cargo run  --no-default-features --features stateless,headers --bin generate-headers
mv -v rln.h rln/ffi_c_examples/

Compile example stateless

cd rln/ffi_c_examples/
gcc -Wall -DSTATELESS main.c -o main -lrln -L../../target/debug
./main

Note

Find C lib used by Rust

cargo +nightly rustc --release -p rln -- -Z unstable-options --print native-static-libs