Cargo.toml [dependencies] libc = "0.2" [lib] name = "" crate-type = ["dylib"] --- lib.rs extern crate libc; use std::ffi::{CStr, CString}; #[no_mangle] pub extern fn lib_fn(name: *const libc::c_char) { let name = unsafe { CStr::from_ptr(name) }; // implementation } --- test.rb require 'ffi' module Test extend FFI::Library ffi_lib 'path/to/lib' attach_function :lib_fn, [:string], :void end Test.lib_fn(str)