Skip to content

jackbkennedy/elixir-rust-nif-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elixir Rust NIF Starter

Example application for implementing Rust NIFs in Elixir using the Elixir Rustler library with tweaks for Apple Silicon.

Installation

These are installation instructions for Mac OS, including some tweaks to get this to work on Apple Silicon using Homebrew.

Install Elixir

brew install rustup

Install Rust

brew install rustup

rustup-init

Create a new Elixir project

mix new nif_starter

add {:rustler, "~> 0.22.2"}

mix deps.get

Create a new Rust package

mix rustler new

Module Name > NifStarter

Library name > nif_starter

Update native/nif_starter/.cargo/config

If you are using Apple Silicon you will need to update the .cargo/config file to build the Rust package

[target.'cfg(target_os = "macos")']
rustflags = [
    "-C", "link-arg=-undefined",
    "-C", "link-arg=dynamic_lookup",
]

Install crates and build Rust package

cargo build

Open IEx and call the NIF

iex -S mix

NifStarter.add(1, 2)

Resources

About

Basic NIF implementation with Elixir and Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published