Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time


I used this library briefly and it works but I am not actively using it, there are multiple reasons:

  • too many layers really slow things down significantly
  • mruby has a well defined C api which is really a pleasure to use (opposite of MRI) and writing a binding directly with it is faster than writing the ffi wrapper for complex cases (and it runs better...).

What is this ?

Abstraction layer on top of mruby-cfunc to mimic the standard ffi ruby gem and allow hybrid gems working on both MRI and mruby.

Check the specs if you want to see what is currently supported. Build Status


module MyLib
  extend FFI::Library
  ffi_lib 'c'
  attach_function :puts, [ :string ], :int

MyLib.puts 'Hello, World using libc!'

Running tests

First you need a standard ruby installed and then:

You need a mruby build with mruby-cfunc, download a copy of the mruby repository:

$ git clone git://

edit build_config.rb to add cfunc (see: for infos) and then build mruby with:

$ rake

add the path to your mruby/bin folder to your path, and now you can set up the test sytem and run it (inside the mruby-rubyffi-compat folder):

$ gem install bundler
$ bundle install
$ bundle exec guard -c

After this any changes to either a rb file of the libtest.c file will trigger a new test run.

To check that the api is compatible with the ruby fi gem the tests can also be executed with a standard ruby with:

$ ruby specs/mri_runner.rb

Supported platforms

The tests pass on:

  • Mac OS X 10.8 64bits (my dev machine)
  • BeagleBone (ARM 32bits cpu) running linux 3.2 kernel
  • Kubuntu (linux) x86_64 3.5.0-17-generic

Design / Goals

My main goal is not to provide 100% coverage for the ffi gem api but to provide a useful subset of it allowing porting gem from ffi to mruby or hybryd gems running on both You can check for an example of such gem.


mruby rubyffi compatibility layer




No releases published


You can’t perform that action at this time.