This repository demonstrates how to achieve interoperability between Scala and Rust by integrating Rust code as a shared library within a Scala Native project.
- Navigate to the rust-module directory.
- Build the Rust code into a shared library (dynamic library) using Cargo:
cd rust-module
cargo build --release
- Run the following command to specify additional directories to search for shared libraries at runtime (required on Linux):
export LD_LIBRARY_PATH=${PWD}/rust-module/target/release/:$LD_LIBRARY_PATH
sbt scalaModule/run
sbt nativeLink
SCALA_VERSION=$(sbt "scalaVersion" | tail -1 | awk '{print $NF}')
./scala-module/target/scala-$SCALA_VERSION/scalamodule
sbt test