Skip to content

serval/dylibs-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dylibs-example

This is a small example repository showing how to write a dynamic library with Rust and how to dynamically load that library from disk in an example program.

Details

The example library exports a function add(u32, u32) -> u32) that adds two numbers.

The demo app accepts the path to a dylib file (.dylib on macOS, .so on Linux), loads it into memory via libloading, and invokes the add function.

Usage

This project uses just (brew install just) for development workflows and automation. Run just with no arguments to see a list of available commands.

Build the library:

just build

Run the example program (which uses the library):

just run

If all goes well, yous hould see something like this:

Loading `add` function from "target/debug/libdylibs_example.dylib" and asking it to add 1 and 2
1 + 2 = Ok(3)

About

A small example repo showing how to dynamically load dylibs from disk in a Rust program

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published