joseluis / codinrust

C+Odin+Rust interop examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

codinrust

A series of examples to showcase how to interoperate between C, Odin and Rust languages.

It shows how to generate both shared and static libraries using C FFI, how to import them both dynamically and statically, in each language.

Status

  • Supported languages
    • C
    • Odin
    • Rust
  • Supported platforms
    • Linux
    • Macos
    • Windows Cygwin (untested)

Example

$ ./do_all.sh
# Compiling libraries in Rust and using them from Odin:
# -----------------------------------------------------
- rust_lib_shared/build.sh . . .
  compiling shared lib . . .
  compiling static lib . . .
- odin_bin/run.sh (dynamic_loading) . . .
---
Hello from Odin. (dynamic loading)
Hello from Rust! (compiled in `rust_lib`)

- odin_bin/run.sh (static_loading) . . .
---
Hello from Odin! (static loading)
Hello from Rust! (compiled in `rust_lib`)
Hello from Rust! (compiled in `rust_lib`)

# Compiling libraries in Odin and using them from Rust:
# -----------------------------------------------------
- odin_lib/build.sh . . .
  compiling shared lib . . .
  compiling static lib . . .
- rust_bin/run.sh (dynamic_loading). . .
---
Hello from Rust. (dynamic loading)
Hello from Odin! (compiled in `odin_lib`)

- rust_bin/run.sh (static_loading). . .
---
Hello from Rust. (static loading)
Hello from Odin! (compiled in `odin_lib`)
Hello from Odin! (compiled in `odin_lib`)

About

C+Odin+Rust interop examples


Languages

Language:Shell 35.7%Language:Rust 33.4%Language:Odin 30.9%